/* Brand colors (see BRAND.md). Dark is the default; light follows the visitor's system. */
:root {
  --bg: #141312;
  --surface: #1c1b19;
  --text: #f4f1ec;
  --muted: #a8a39c;
  --border: #2e2c29;
  --accent: #ff4f1f;
  --accent-soft: #3a1e14;
  --on-accent: #141312;
  --danger: #ff6b5e;
  --success: #4cc38a;
  --radius: 10px;
  color-scheme: dark light;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf8f5;
    --surface: #ffffff;
    --text: #1a1918;
    --muted: #6e6862;
    --border: #e4dfd8;
    --accent: #c93a10;
    --accent-soft: #fbe6dd;
    --on-accent: #ffffff;
    --danger: #c42b1c;
    --success: #1f7a4d;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

p {
  margin: 0 0 16px;
}

a {
  color: var(--accent);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Site header: the mark and wordmark, plus a link back to the tools */
.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 40px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.mark {
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--accent);
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-header nav a:hover {
  color: var(--text);
}

.site-footer {
  margin-top: 64px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0;
}

/* Home page intro */
.hero {
  margin-bottom: 40px;
}

.hero h1 {
  font-size: clamp(2rem, 7vw, 2.75rem);
  line-height: 1.1;
  margin-bottom: 12px;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero .lead {
  font-size: 1.1rem;
  max-width: 34em;
  margin: 0;
}

.lead {
  color: var(--muted);
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

/* Home page links */
.tools {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.tools a {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.tools a:hover,
.tools a:focus-visible {
  border-color: var(--accent);
}

.tools strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.tools a:hover strong,
.tools a:focus-visible strong {
  color: var(--accent);
}

.tools span {
  color: var(--muted);
}

/* Form controls */
input,
select,
button {
  font: inherit;
  color: inherit;
}

input[type="number"],
select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

input[type="number"]:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

button {
  padding: 8px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
}

/* A sentence-style row: "What is [ ] % of [ ] ? = result" */
.sentence {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.sentence input {
  width: 110px;
}

.result {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--accent);
  min-width: 4ch;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 8px;
  margin-bottom: 16px;
}

.row .sep {
  padding-bottom: 8px;
  color: var(--muted);
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

/* Home page group headings */
.group {
  margin: 32px 0 12px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Wider pages (tables, side-by-side panes) */
main.wide {
  max-width: 960px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
}

.field {
  margin-bottom: 12px;
}

input[type="text"],
input[type="color"],
textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: inherit;
}

input[type="color"] {
  padding: 2px;
  height: 40px;
  cursor: pointer;
}

input[type="text"]:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

textarea {
  min-height: 200px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* Segmented toggle built from radio buttons */
.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
}

.tabs label {
  margin: 0;
  padding: 8px 14px;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
}

.tabs input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tabs label:has(input:checked) {
  background: var(--accent);
  color: var(--on-accent);
}

.tabs label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Number tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 6px 4px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td.num,
th.num {
  text-align: right;
}

/* Lets a wide table scroll inside its card instead of widening the page */
.table-scroll {
  overflow-x: auto;
}

tr.total td {
  font-weight: 600;
  border-bottom: none;
}

.big {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.error {
  color: var(--danger);
}

.ok {
  color: var(--success);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 0.95rem;
}

/* Motion: short and gentle, so it stays calm. Turned off for visitors who prefer reduced motion. */
:root {
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --fast: 120ms;
  --slow: 200ms;
}

a,
button,
input,
select,
textarea,
.tabs label {
  transition:
    color var(--slow) var(--ease),
    background-color var(--slow) var(--ease),
    border-color var(--slow) var(--ease),
    transform var(--fast) var(--ease);
}

/* Tool cards lift slightly, and an arrow slides in beside the name */
.tools a:hover {
  transform: translateY(-2px);
}

.tools a:active {
  transform: translateY(0) scale(0.99);
}

.tools strong::after {
  content: "→";
  content: "→" / "";
  display: inline-block;
  margin-left: 6px;
  opacity: 0;
  transform: translateX(-4px);
  transition:
    opacity var(--slow) var(--ease),
    transform var(--slow) var(--ease);
}

.tools a:hover strong::after,
.tools a:focus-visible strong::after {
  opacity: 1;
  transform: translateX(0);
}

/* Buttons press in */
button:active,
.tabs label:active {
  transform: scale(0.97);
}

/* The mark turns a little, like the eclipse moving */
.brand .mark {
  transition: transform 400ms var(--ease);
}

.brand:hover .mark {
  transform: rotate(-25deg);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }

  .tools a:hover,
  .brand:hover .mark {
    transform: none;
  }
}
