/* Grammar theory pages. Tokens come from main.css, page scaffolding from exercises.css. */

/* Overview: level switch */
.g-levels { display: grid; gap: 10px; margin-bottom: 40px; }
.g-levels .filter { display: inline-flex; align-items: center; gap: 8px; padding-left: 8px; }
.g-levels .filter[aria-pressed="true"] .level-tag { background: #fff; color: var(--ink); }
.g-levels__note { color: var(--ink-2); font-size: 0.95rem; max-width: 42em; }
.g-levels__note:empty { display: none; }

.g-subtitle { margin-top: 10px; font-size: 1.15rem; font-weight: 500; max-width: 40em; }

.g-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
}

.g-article { min-width: 0; }

.g-section + .g-section { margin-top: 48px; padding-top: 40px; border-top: 1.5px solid var(--line); }
.g-section > * + * { margin-top: 18px; }

.g-h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  line-height: 1.2;
  scroll-margin-top: 96px;
}
.g-section { scroll-margin-top: 96px; }

.g-p, .g-list { max-width: 42em; }
.g-list { display: grid; gap: 8px; padding-left: 0; }
.g-list li { position: relative; padding-left: 22px; }
.g-list li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-2);
}

.g-hl {
  font-weight: 600;
  border-radius: 3px;
  background: rgba(29, 43, 36, 0.07);
  box-shadow: 0 0 0 2px rgba(29, 43, 36, 0.07);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Remember box */
.g-rule {
  max-width: 44em;
  padding: 14px 18px;
  border-left: 4px solid var(--ink);
  border-radius: 0 var(--r-s) var(--r-s) 0;
  background: var(--band);
}
.g-rule__label { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }

/* Tables */
.g-table { border-collapse: collapse; min-width: min(100%, 460px); font-size: 1rem; }
.g-table caption { caption-side: top; text-align: left; padding-bottom: 8px; color: var(--ink-2); font-size: 0.92rem; }
.g-table th, .g-table td { padding: 9px 18px 9px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.g-table thead th { font-size: 0.88rem; font-weight: 600; color: var(--ink-2); border-bottom-width: 1.5px; }
.g-table tbody th { font-weight: 600; white-space: nowrap; }
.g-table .g-der, .g-table .g-die, .g-table .g-das { font-weight: 500; }
.g-table thead .g-der { color: var(--der); }
.g-table thead .g-die { color: var(--die-ink); }
.g-table thead .g-das { color: var(--das); }

/* Examples */
.g-examples { display: grid; gap: 8px; max-width: 46em; }
.g-ex {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px 10px 16px;
  border-radius: var(--r-s);
  background: var(--surface);
  border: 1.5px solid var(--line);
}
.g-ex__text { min-width: 0; }
.g-ex__de { font-size: 1.08rem; }
.g-ex__en { margin-top: 2px; font-size: 0.93rem; color: var(--ink-2); }

.g-play {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 200ms ease, transform 160ms var(--ease-out);
}
.g-play:active { transform: scale(0.94); }
.g-play.is-speaking { background: var(--band); }
@media (hover: hover) and (pointer: fine) {
  .g-play:hover { background: var(--band); }
}

/* Typical mistake */
.g-pitfall {
  max-width: 44em;
  padding: 14px 18px;
  border-radius: var(--r-m);
  border: 1.5px dashed var(--wrong);
  background: #FDF4F2;
}
.g-pitfall__label { font-weight: 600; font-size: 0.9rem; color: var(--wrong); margin-bottom: 8px; }
.g-pitfall__pair { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: baseline; }
.g-pitfall__pair dt { font-size: 0.9rem; color: var(--ink-2); }
.is-wrong-text { color: var(--wrong); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.is-right-text { color: #1F6437; font-weight: 600; }
.is-wrong-text .g-hl, .is-right-text .g-hl { background: transparent; box-shadow: none; }
.g-pitfall__why { margin-top: 10px; font-size: 0.97rem; }

/* Sidebar */
.g-aside { position: sticky; top: 96px; display: grid; gap: 28px; }
.g-aside__title { font-size: 0.95rem; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.g-toc ol { display: grid; gap: 2px; counter-reset: none; }
.g-toc a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: var(--r-s);
  text-decoration: none;
  font-size: 0.97rem;
  line-height: 1.3;
  transition: background-color 200ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .g-toc a:hover { background: var(--band); }
}
.g-toc .g-hl { background: transparent; box-shadow: none; font-weight: 500; }

.g-practice { padding: 16px; border-radius: var(--r-m); background: var(--surface); border: 1.5px solid var(--line); }
.g-practice ul { display: grid; gap: 4px; }
.g-practice a {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  padding: 8px;
  margin-inline: -8px;
  border-radius: var(--r-s);
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.35;
  transition: background-color 200ms ease;
}
.g-practice .level-tag { margin-top: 2px; }
.g-practice__text { display: grid; }
.g-practice__text b { font-weight: 600; }
.g-practice__text > span { color: var(--ink-2); font-size: 0.88rem; }
.g-practice__text .g-hl { background: transparent; box-shadow: none; }
@media (hover: hover) and (pointer: fine) {
  .g-practice a:hover { background: var(--band); }
}

/* Previous / next */
.g-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1.5px solid var(--line);
}
.g-pager:empty { display: none; }
.g-pager__link {
  display: grid;
  gap: 2px;
  min-width: min(100%, 260px);
  padding: 14px 18px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 200ms ease;
}
.g-pager__link.is-next { margin-left: auto; text-align: right; }
.g-pager__dir { font-size: 0.88rem; color: var(--ink-2); }
.g-pager__title { font-family: var(--font-display); font-size: 1.2rem; }
@media (hover: hover) and (pointer: fine) {
  .g-pager__link:hover { border-color: var(--ink); }
}

@media (max-width: 960px) {
  .g-layout { grid-template-columns: 1fr; }
  .g-aside { position: static; }
  .g-toc { display: none; }
}

@media (max-width: 600px) {
  .g-table th, .g-table td { padding-right: 12px; font-size: 0.95rem; }
  /* Wide tables scroll sideways instead of squeezing cells to one word per line. */
  .g-table td { min-width: 6.5rem; }
  .g-pager__link, .g-pager__link.is-next { flex: 1 1 100%; margin-left: 0; }
}

.g-related ul { display: grid; gap: 2px; }
.g-related a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 10px;
  margin-inline: -10px;
  border-radius: var(--r-s);
  font-weight: 500;
  text-underline-offset: 4px;
  transition: background-color 200ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .g-related a:hover { background: var(--band); }
}
