/* Grind Converter
   Same skeleton as the rest of the site: the logo card hangs where the avatar
   does, every block starts at 144px (gutter 24 + card 88 + gap 32) and ends at
   the container edge. Type: IBM Plex Mono for headings and numbers, Helvetica
   for labels and text. One card style for every panel. */

.page--grind {
  --grind-surface: #0d0d0d;
  --grind-field: #161616;
  --grind-line: rgb(255 255 255 / 10%);
  --grind-line-strong: rgb(255 255 255 / 16%);
  --grind-good: #65c879;
  --grind-mid: #e8b75a;
  --grind-low: #ff786f;
  --grind-f1: #2b6bff;
  --grind-f2: #5a8cff;
  --grind-f3: #93b4ff;
  --grind-f4: #d0deff;
  background: var(--color-bg);
}

.l-page-shell--grind {
  width: min(100%, var(--container-max));
  margin: 0 auto;
}

.grind-logo {
  display: block;
  width: 88px;
  height: 140px;
  object-fit: cover;
}

.g-shell {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding-left: calc(var(--page-gutter) + 88px + 32px);
  padding-right: var(--page-gutter);
}

/* ── Intro ────────────────────────────────────────────────────── */

.grind-intro {
  padding-top: 22px;
}

.grind-kicker {
  display: flex;
  gap: 10px;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 20px;
}

.grind-kicker a {
  color: var(--color-link);
}

.grind-kicker a:hover {
  color: var(--color-link-hover);
}

.grind-title {
  margin-top: 12px;
  max-width: 900px;
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-size: 48px;
  line-height: 56px;
  font-weight: 500;
  text-wrap: balance;
}

.grind-lead {
  margin-top: 16px;
  max-width: 760px;
  color: var(--color-text-primary);
  font-family: var(--font-ui);
  font-size: 24px;
  line-height: 32px;
}

.grind-link {
  color: var(--color-link);
  transition: color var(--transition-fast);
}

.grind-link:hover {
  color: var(--color-link-hover);
}

/* ── Converter ────────────────────────────────────────────────── */

.grind-tool {
  margin-top: 56px;
}

.converter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  padding: 32px;
  border: 1px solid var(--grind-line);
  border-radius: 16px;
  background: var(--grind-surface);
}

.converter__side {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.converter__legend {
  margin-bottom: 20px;
  padding: 0;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.converter__field + .converter__field {
  margin-top: 20px;
}

.converter label {
  display: block;
  margin-bottom: 8px;
  color: var(--color-text-secondary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 24px;
}

.converter__select {
  position: relative;
}

.converter__select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 18px;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid rgb(255 255 255 / 60%);
  border-bottom: 1.5px solid rgb(255 255 255 / 60%);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.converter select {
  width: 100%;
  height: 52px;
  padding: 0 44px 0 16px;
  border: 1px solid var(--grind-line-strong);
  border-radius: 10px;
  background: var(--grind-field);
  color: var(--color-text-primary);
  font-family: var(--font-ui);
  font-size: 18px;
  line-height: 24px;
  text-overflow: ellipsis;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition-fast);
}

.converter select:hover {
  border-color: rgb(255 255 255 / 30%);
}

.converter select:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

.converter select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.converter option {
  background: var(--grind-field);
  color: var(--color-text-primary);
}

.converter__hint {
  min-height: 20px;
  margin-top: 8px;
  color: var(--color-text-secondary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
}

.converter__swap {
  align-self: center;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--grind-line-strong);
  border-radius: 50%;
  background: var(--grind-field);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-medium);
}

.converter__swap:hover {
  border-color: var(--color-accent);
  color: var(--color-link-hover);
}

.converter__swap:active {
  transform: rotate(180deg);
}

.converter__swap:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 3px;
}

.result {
  margin-top: 20px;
  padding: 20px 24px 22px;
  border: 1px solid rgb(43 107 255 / 40%);
  border-radius: 12px;
  background: rgb(43 107 255 / 10%);
}

.result__label {
  color: #9ec0ff;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 24px;
}

.result__value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-top: 4px;
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-size: 56px;
  line-height: 64px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.result__unit {
  color: var(--color-text-secondary);
  font-family: var(--font-ui);
  font-size: 24px;
  line-height: 32px;
  font-weight: 400;
}

.result__range {
  margin-top: 8px;
  color: var(--color-text-secondary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
}

/* ── Details ──────────────────────────────────────────────────── */

.grind-details {
  margin-top: 120px;
  display: flex;
  flex-direction: column;
  gap: 96px;
}

.grind-row {
  display: grid;
  grid-template-columns: minmax(0, 444px) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

.grind-label {
  color: var(--color-text-secondary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 24px;
}

.grind-h2 {
  margin-top: 8px;
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 40px;
  font-weight: 500;
  text-wrap: balance;
}

.grind-text {
  margin-top: 12px;
  color: var(--color-text-primary);
  font-family: var(--font-ui);
  font-size: 20px;
  line-height: 28px;
}

.grind-card {
  min-width: 0;
  margin: 0;
  padding: 24px;
  border: 1px solid var(--grind-line);
  border-radius: 16px;
  background: var(--grind-surface);
}

.grind-card__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--color-text-secondary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 24px;
}

.match {
  font-family: var(--font-mono);
  font-size: 14px;
}

.match[data-level="high"],
.match[data-level="good"] { color: var(--grind-good); }
.match[data-level="medium"] { color: var(--grind-mid); }
.match[data-level="low"] { color: var(--grind-low); }

.fraction-bar {
  display: flex;
  gap: 2px;
  height: 14px;
  margin: 20px 0 24px;
  overflow: hidden;
  border-radius: 7px;
  background: var(--grind-field);
}

.fraction-bar span {
  flex: 0 0 0%;
  min-width: 0;
  transition: flex-basis 360ms cubic-bezier(0.2, 0.65, 0.12, 1);
}

.fraction-bar span:nth-child(1),
.swatch--1 { background: var(--grind-f1); }
.fraction-bar span:nth-child(2),
.swatch--2 { background: var(--grind-f2); }
.fraction-bar span:nth-child(3),
.swatch--3 { background: var(--grind-f3); }
.fraction-bar span:nth-child(4),
.swatch--4 { background: var(--grind-f4); }

.fraction-legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}

.fraction-legend dt {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-secondary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
}

.swatch {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 3px;
}

.fraction-legend dd,
.grind-facts dt {
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.fraction-legend dd {
  margin: 6px 0 0;
  font-size: 24px;
  line-height: 32px;
}

.grind-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grind-facts > div {
  min-width: 0;
  padding-right: 24px;
}

.grind-facts > div + div {
  padding-left: 24px;
  border-left: 1px solid var(--grind-line);
}

.grind-facts dt {
  font-size: 48px;
  line-height: 56px;
}

.grind-facts dd {
  margin: 8px 0 0;
  color: var(--color-text-secondary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 24px;
}

.grind-card__title {
  margin-bottom: 8px;
  color: var(--color-text-secondary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 24px;
}

.grind-sources a {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--grind-line);
  color: var(--color-link);
  font-family: var(--font-ui);
  font-size: 20px;
  line-height: 28px;
  transition: color var(--transition-fast);
}

.grind-sources a:first-of-type {
  border-top: 1px solid var(--grind-line);
}

.grind-sources a:hover {
  color: var(--color-link-hover);
}

.grind-sources a:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

.grind-card__note {
  margin-top: 16px;
  color: var(--color-text-secondary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
}

.page--grind .site-footer {
  margin-top: 120px;
}

/* ── Smaller screens ──────────────────────────────────────────── */

@media (max-width: 1100px) {
  .g-shell {
    padding-left: var(--page-gutter-mobile);
    padding-right: var(--page-gutter-mobile);
  }

  .grind-intro {
    padding-top: 188px;
  }

  .grind-title {
    font-size: 42px;
    line-height: 50px;
  }

  .converter {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 24px;
  }

  .converter__swap {
    justify-self: center;
    transform: rotate(90deg);
  }

  .converter__swap:active {
    transform: rotate(270deg);
  }

  .grind-details {
    margin-top: 88px;
    gap: 72px;
  }

  .grind-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
}

@media (max-width: 768px) {
  .grind-title {
    font-size: clamp(30px, 9vw, 42px);
    line-height: 1.15;
  }

  .grind-lead {
    font-size: 20px;
    line-height: 28px;
  }

  .converter {
    padding: 20px 16px;
  }

  .result__value {
    font-size: 44px;
    line-height: 52px;
  }

  .grind-h2 {
    font-size: 28px;
    line-height: 36px;
  }

  .grind-text {
    font-size: 18px;
    line-height: 26px;
  }

  .fraction-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 12px;
  }

  .grind-facts {
    grid-template-columns: minmax(0, 1fr);
    padding-block: 8px;
  }

  .grind-facts > div,
  .grind-facts > div + div {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 12px 0;
    border-left: 0;
  }

  .grind-facts > div + div {
    border-top: 1px solid var(--grind-line);
  }

  .grind-facts dt {
    min-width: 56px;
    font-size: 32px;
    line-height: 40px;
  }

  .grind-facts dd {
    margin: 0;
  }

  .grind-sources a {
    font-size: 18px;
    line-height: 26px;
  }

  .page--grind .site-footer {
    margin-top: 88px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fraction-bar span,
  .converter__swap {
    transition: none;
  }
}
