:root {
  --ink: #18251f;
  --muted: #617067;
  --paper: #f7f2e7;
  --paper-deep: #eee5d3;
  --white: #fffdf8;
  --green: #215844;
  --green-dark: #143c2d;
  --gold: #b98032;
  --gold-soft: #ead7af;
  --line: #d8cdb9;
  --danger: #8b3e35;
  --shadow: 0 22px 60px rgba(30, 48, 38, .12);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(185, 128, 50, .11), transparent 32rem),
    linear-gradient(180deg, var(--paper) 0, #fbf8f1 42rem, var(--white) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.68;
}

a { color: var(--green); text-underline-offset: 3px; }
a:hover { color: var(--green-dark); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: .65rem 1rem;
  color: #fff;
  background: var(--green-dark);
  border-radius: 8px;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  border-bottom: 1px solid rgba(117, 105, 82, .18);
  background: rgba(247, 242, 231, .88);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 30;
}
.nav-wrap, .container { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
.nav-wrap { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.brand { display: inline-flex; align-items: center; gap: .72rem; text-decoration: none; color: var(--ink); font-weight: 760; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; border: 1px solid var(--green); border-radius: 50%; display: grid; place-items: center; font: 700 21px Georgia, serif; color: var(--green); }
.site-nav { display: flex; align-items: center; gap: 1.3rem; font-size: .94rem; }
.site-nav a { color: var(--ink); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--green); }
.nav-tool { padding: .55rem .85rem; border: 1px solid var(--green); border-radius: 999px; }

main { min-height: 70vh; }
.hero { padding: 5.4rem 0 3.5rem; }
.hero.compact { padding-bottom: 2.3rem; }
.eyebrow { margin: 0 0 .7rem; color: var(--green); text-transform: uppercase; letter-spacing: .14em; font-weight: 760; font-size: .76rem; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; color: var(--ink); line-height: 1.12; letter-spacing: -.025em; }
h1 { font-size: clamp(2.7rem, 7vw, 5.4rem); margin: 0; max-width: 900px; font-weight: 500; }
.compact h1 { font-size: clamp(2.5rem, 5vw, 4.5rem); }
h2 { font-size: clamp(1.9rem, 4vw, 3rem); margin: 0 0 1.2rem; font-weight: 500; }
h3 { font-size: 1.35rem; margin: 0 0 .5rem; }
.lede { max-width: 720px; margin: 1.25rem 0 0; color: var(--muted); font-size: clamp(1.08rem, 2.1vw, 1.35rem); }
.hero-rule { display: flex; gap: 1rem; align-items: center; margin-top: 2.2rem; color: var(--muted); font-size: .88rem; }
.hero-rule::before { content: ""; width: 55px; border-top: 1px solid var(--gold); }

.translator-shell { margin-top: 2.5rem; padding: clamp(1rem, 3vw, 1.65rem); background: rgba(255, 253, 248, .94); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.direction-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--paper-deep); border-radius: 999px; }
.direction-button { border: 0; border-radius: 999px; padding: .58rem .85rem; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; font-size: .86rem; }
.direction-button[aria-pressed="true"] { color: #fff; background: var(--green); }
.sample-button { border: 0; background: none; color: var(--green); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: .9rem; }
.input-label { display: block; margin: 0 0 .45rem; font-weight: 760; font-size: .9rem; }
#translation-input { width: 100%; min-height: 166px; resize: vertical; padding: 1.05rem; border: 1px solid #cabeaa; border-radius: 14px; color: var(--ink); background: #fffefa; line-height: 1.55; }
#translation-input:focus, .search-field:focus { outline: 3px solid rgba(33, 88, 68, .16); border-color: var(--green); }
.tool-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .8rem; }
.privacy-note { color: var(--muted); font-size: .82rem; }
.primary-button { border: 1px solid var(--green); background: var(--green); color: #fff; border-radius: 12px; padding: .78rem 1.15rem; font-weight: 760; cursor: pointer; box-shadow: 0 8px 20px rgba(33, 88, 68, .18); }
.primary-button:hover { background: var(--green-dark); }

.results { display: none; margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1.25rem; }
.results.is-visible { display: block; }
.result-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.5fr); gap: 1rem; }
.result-card { border: 1px solid var(--line); border-radius: 14px; padding: 1rem; background: #fff; }
.result-card h3 { font-family: inherit; font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.translation-output { font-family: Georgia, serif; font-size: 1.25rem; line-height: 1.55; }
.uncertainty { display: flex; gap: .65rem; margin-top: 1rem; padding: .85rem 1rem; color: var(--danger); background: #fbefec; border: 1px solid #edc8c1; border-radius: 12px; font-size: .9rem; }
.uncertainty[hidden] { display: none; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
table { border-collapse: collapse; width: 100%; min-width: 620px; font-size: .93rem; }
th, td { text-align: left; vertical-align: top; padding: .82rem .9rem; border-bottom: 1px solid #e9e1d3; }
th { color: var(--green-dark); background: #f4eee2; font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.old-english { font-family: Georgia, "Times New Roman", serif; font-size: 1.08em; }

.section { padding: 4.5rem 0; }
.section.muted { background: rgba(234, 224, 205, .35); border-top: 1px solid rgba(117, 105, 82, .14); border-bottom: 1px solid rgba(117, 105, 82, .14); }
.narrow { width: min(760px, 100%); }
.prose p { margin: 0 0 1.1rem; }
.steps, .card-grid, .link-grid, .entries { display: grid; gap: 1rem; }
.steps { grid-template-columns: repeat(3, 1fr); counter-reset: steps; }
.step, .content-card, .link-card, .entry { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255, 253, 248, .82); padding: 1.25rem; }
.step::before { counter-increment: steps; content: counter(steps); width: 30px; height: 30px; display: grid; place-items: center; margin-bottom: 1rem; border-radius: 50%; color: #fff; background: var(--green); font-weight: 800; font-size: .8rem; }
.step p, .content-card p { color: var(--muted); margin: .4rem 0 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.callout { padding: 1.4rem; border-left: 4px solid var(--gold); background: #fff8e9; border-radius: 0 var(--radius) var(--radius) 0; }
.faq details { border-top: 1px solid var(--line); padding: 1.15rem 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-family: Georgia, serif; font-size: 1.15rem; font-weight: 700; }
.faq details p { max-width: 740px; color: var(--muted); }
.link-grid { grid-template-columns: repeat(3, 1fr); }
.link-card { color: var(--ink); text-decoration: none; transition: transform .18s ease, border-color .18s ease; }
.link-card:hover { transform: translateY(-3px); border-color: var(--gold); color: var(--ink); }
.link-card span { display: block; color: var(--muted); font-size: .9rem; margin-top: .3rem; }

.search-panel { padding: 1.25rem; margin: 0 0 2rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 15px 45px rgba(30, 48, 38, .07); }
.search-field { width: 100%; padding: .85rem 1rem; border: 1px solid #cabeaa; border-radius: 12px; }
.alphabet { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.alphabet a { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; font-weight: 760; font-size: .85rem; }
.entries { grid-template-columns: 1fr 1fr; }
.entry[hidden] { display: none; }
.entry-meta { color: var(--green); font-weight: 760; font-size: .82rem; }
.entry h3 { font-size: 1.75rem; }
.entry p { margin: .45rem 0; }
.entry-example { color: var(--muted); font-style: italic; }
.no-results { display: none; color: var(--muted); }
.no-results.is-visible { display: block; }

.category { margin-bottom: 3.5rem; scroll-margin-top: 95px; }
.category h2 { font-size: 2rem; }
.phrase-list { display: grid; gap: 1.1rem; }
.phrase { padding: 1.4rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.phrase blockquote { margin: 0 0 .85rem; font: 1.45rem/1.4 Georgia, serif; color: var(--green-dark); }
.phrase dl { display: grid; grid-template-columns: 105px 1fr; gap: .45rem 1rem; margin: 0; }
.phrase dt { color: var(--muted); font-weight: 760; font-size: .84rem; }
.phrase dd { margin: 0; }
.grammar-example { margin: .8rem 0 0; padding: 1rem; background: var(--paper); border-radius: 12px; }

.beowulf-nav { position: sticky; top: 88px; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 253, 248, .95); }
.beowulf-nav a { display: block; padding: .35rem 0; text-decoration: none; font-size: .9rem; }
.beowulf-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 2rem; align-items: start; }
.passage { margin-bottom: 1.6rem; padding: 1.35rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; scroll-margin-top: 95px; }
.passage-label { color: var(--green); text-transform: uppercase; letter-spacing: .08em; font-weight: 800; font-size: .76rem; }
.passage-text { white-space: pre-line; font: 1.08rem/1.72 Georgia, serif; }
.translation-text { white-space: pre-line; color: #33473d; }
.note { margin-top: 1rem; padding: .9rem 1rem; color: var(--muted); background: var(--paper); border-radius: 12px; font-size: .9rem; }

.site-footer { margin-top: 4rem; padding: 2.5rem 0; color: #dfe8e2; background: var(--green-dark); }
.footer-grid { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; }
.site-footer a { color: #fff; }
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }
.footer-copy { color: #b8cbc0; font-size: .88rem; max-width: 520px; }

@media (max-width: 840px) {
  .site-nav a:not(.nav-tool) { display: none; }
  .hero { padding-top: 3.7rem; }
  .result-grid, .two-col, .entries, .beowulf-layout { grid-template-columns: 1fr; }
  .steps, .link-grid { grid-template-columns: 1fr 1fr; }
  .beowulf-nav { position: static; display: flex; gap: .75rem; overflow-x: auto; }
  .beowulf-nav a { flex: 0 0 auto; }
}

@media (max-width: 580px) {
  body { font-size: 16px; }
  .nav-wrap, .container { width: min(100% - 24px, 1120px); }
  .brand span:last-child { display: none; }
  .steps, .link-grid { grid-template-columns: 1fr; }
  .direction-row, .tool-actions, .footer-grid { align-items: stretch; flex-direction: column; }
  .segmented { display: grid; grid-template-columns: 1fr 1fr; border-radius: 14px; }
  .direction-button { border-radius: 10px; padding: .7rem .55rem; }
  .primary-button { width: 100%; }
  .phrase dl { grid-template-columns: 1fr; gap: .1rem; }
  .phrase dd { margin-bottom: .65rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
