:root {
  --navy-950: #04111f;
  --navy-900: #071a2f;
  --navy-800: #102d46;
  --navy-700: #1c4260;
  --ivory: #f4ecd8;
  --paper: #fbf7ed;
  --paper-deep: #efe5d0;
  --copper: #c98643;
  --copper-dark: #965d2b;
  --ink: #142331;
  --muted: #5d6872;
  --line: rgba(20, 35, 49, 0.16);
  --danger: #a63737;
  --shadow: 0 20px 60px rgba(4, 17, 31, 0.14);
  --radius: 18px;
  --content: 1160px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 10%, rgba(201, 134, 67, 0.08), transparent 32rem),
    radial-gradient(circle at 90% 45%, rgba(16, 45, 70, 0.08), transparent 36rem);
}

[hidden] {
  display: none !important;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button,
textarea,
select,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid #f0a65a;
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  color: var(--navy-950);
  background: var(--ivory);
  border-radius: 8px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.masthead {
  position: relative;
  color: var(--ivory);
  background:
    radial-gradient(circle at 50% 35%, rgba(28, 66, 96, 0.72), transparent 28rem),
    linear-gradient(180deg, var(--navy-950), var(--navy-900));
  border-bottom: 1px solid rgba(244, 236, 216, 0.16);
}

.brand-row {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 270px;
  padding: 16px 24px 10px;
}

.brand-link {
  display: block;
  width: min(250px, 60vw);
  border-radius: 24px;
}

.brand-link img {
  width: 100%;
  height: auto;
  border-radius: 24px;
}

.language-switcher {
  position: absolute;
  top: 18px;
  right: 22px;
  display: flex;
  gap: 8px;
  padding: 7px;
  background: rgba(4, 17, 31, 0.72);
  border: 1px solid rgba(244, 236, 216, 0.18);
  border-radius: 999px;
  backdrop-filter: blur(10px);
}

.language-button {
  width: 42px;
  height: 32px;
  padding: 4px;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  opacity: 0.65;
  transition: opacity 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.language-button:hover,
.language-button.is-active {
  opacity: 1;
  border-color: var(--copper);
  transform: translateY(-1px);
}

.language-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 999px;
}

.navigation-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  color: var(--ivory);
  background: rgba(4, 17, 31, 0.96);
  border-bottom: 1px solid rgba(244, 236, 216, 0.13);
  backdrop-filter: blur(12px);
}

.navigation-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: var(--content);
  min-height: 58px;
  margin: 0 auto;
  padding: 0 22px;
}

.navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.navigation a {
  padding: 9px 15px;
  color: rgba(244, 236, 216, 0.78);
  text-decoration: none;
  border-radius: 999px;
  transition: color 160ms ease, background 160ms ease;
}

.navigation a:hover,
.navigation a[aria-current="page"] {
  color: var(--ivory);
  background: rgba(201, 134, 67, 0.18);
}

.menu-toggle {
  display: none;
  margin-left: auto;
  padding: 8px 12px;
  color: var(--ivory);
  cursor: pointer;
  background: transparent;
  border: 1px solid rgba(244, 236, 216, 0.22);
  border-radius: 10px;
}

main {
  min-height: 55vh;
}

.section {
  padding: 76px 22px;
}

.section--compact {
  padding-top: 44px;
  padding-bottom: 44px;
}

.section--navy {
  color: var(--ivory);
  background:
    linear-gradient(rgba(7, 26, 47, 0.95), rgba(7, 26, 47, 0.98)),
    radial-gradient(circle at center, var(--navy-700), var(--navy-950));
}

.section--paper-deep {
  background: var(--paper-deep);
}

.container {
  width: min(100%, var(--content));
  margin: 0 auto;
}

.container--narrow {
  width: min(100%, 830px);
}

.hero {
  padding-top: 92px;
  padding-bottom: 88px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--copper-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section--navy .eyebrow {
  color: #eda85f;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.18;
}

h1 {
  max-width: 820px;
  margin-right: auto;
  margin-bottom: 20px;
  margin-left: auto;
  font-size: clamp(2.6rem, 7vw, 5.2rem);
  font-weight: 500;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 16px;
  font-size: clamp(2rem, 4.2vw, 3.3rem);
  font-weight: 500;
  letter-spacing: -0.025em;
}

h3 {
  font-size: 1.32rem;
}

.lead {
  max-width: 790px;
  margin-right: auto;
  margin-bottom: 0;
  margin-left: auto;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
}

.section--navy .lead {
  color: rgba(244, 236, 216, 0.78);
}

.question-card,
.content-card,
.code-panel,
.ai-panel {
  padding: clamp(24px, 5vw, 48px);
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(20, 35, 49, 0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.form-label {
  display: block;
  margin-bottom: 10px;
  font-weight: 800;
}

.question-input {
  width: 100%;
  min-height: 145px;
  padding: 16px 18px;
  color: var(--ink);
  resize: vertical;
  background: #fffef9;
  border: 1px solid rgba(20, 35, 49, 0.24);
  border-radius: 12px;
}

.question-input:focus {
  border-color: var(--copper-dark);
  box-shadow: 0 0 0 4px rgba(201, 134, 67, 0.15);
  outline: none;
}

.hint {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.check-row {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin: 20px 0;
}

.check-row input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 3px;
  accent-color: var(--copper-dark);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.button {
  display: inline-flex;
  min-height: 46px;
  padding: 11px 18px;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  background: var(--copper-dark);
  border: 1px solid transparent;
  border-radius: 999px;
  box-shadow: 0 9px 22px rgba(150, 93, 43, 0.18);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.button:hover:not(:disabled):not(.is-disabled) {
  background: #7d4922;
  box-shadow: 0 12px 28px rgba(150, 93, 43, 0.25);
  transform: translateY(-2px);
}

.button--secondary {
  color: var(--navy-900);
  background: transparent;
  border-color: rgba(7, 26, 47, 0.32);
  box-shadow: none;
}

.section--navy .button--secondary {
  color: var(--ivory);
  border-color: rgba(244, 236, 216, 0.35);
}

.button--secondary:hover:not(:disabled) {
  color: var(--navy-950);
  background: var(--ivory);
}

.button:disabled,
.button.is-disabled {
  cursor: not-allowed;
  opacity: 0.52;
  box-shadow: none;
}

.form-message {
  min-height: 1.5em;
  margin-top: 12px;
  margin-bottom: 0;
  color: var(--muted);
}

.form-message.is-error {
  color: var(--danger);
  font-weight: 700;
}

.draw-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 22px;
  align-items: end;
  margin-bottom: 26px;
}

.selection-counter {
  min-width: 120px;
  padding: 11px 16px;
  text-align: center;
  background: rgba(244, 236, 216, 0.08);
  border: 1px solid rgba(244, 236, 216, 0.19);
  border-radius: 12px;
}

.selection-counter span:first-child {
  display: block;
  color: rgba(244, 236, 216, 0.62);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#selection-count {
  display: block;
  margin-top: 2px;
  color: var(--ivory);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(4px, 0.9vw, 10px);
  width: min(100%, 760px);
  margin: 0 auto 26px;
}

.deck-card {
  position: relative;
  aspect-ratio: 76 / 127;
  padding: 0;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: clamp(3px, 0.8vw, 9px);
  perspective: 900px;
}

.deck-card:disabled:not(.is-selected) {
  cursor: default;
  opacity: 0.42;
}

.deck-card__inner {
  position: absolute;
  inset: 0;
  display: block;
  transition: transform 520ms cubic-bezier(0.2, 0.72, 0.2, 1);
  transform-style: preserve-3d;
}

.deck-card.is-selected .deck-card__inner {
  transform: rotateY(180deg);
}

.deck-card__face {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  background: var(--navy-950);
  border: 1px solid rgba(244, 236, 216, 0.28);
  border-radius: inherit;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.24);
  backface-visibility: hidden;
}

.deck-card__front {
  transform: rotateY(180deg);
}

.deck-card__face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.deck-card__order {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  display: grid;
  width: clamp(17px, 2.5vw, 25px);
  height: clamp(17px, 2.5vw, 25px);
  place-items: center;
  color: var(--navy-950);
  font-size: clamp(0.6rem, 1.25vw, 0.82rem);
  font-weight: 900;
  background: var(--copper);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 180ms ease 300ms, transform 180ms ease 300ms;
}

.deck-card.is-selected .deck-card__order {
  opacity: 1;
  transform: scale(1);
}

.draw-actions {
  justify-content: center;
}

.reading-layout {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 22px);
  margin: 38px 0 56px;
}

.layout-card {
  min-width: 0;
  margin: 0;
}

.layout-card img {
  width: 100%;
  height: auto;
  border: 1px solid rgba(20, 35, 49, 0.16);
  border-radius: 9px;
  box-shadow: 0 12px 28px rgba(4, 17, 31, 0.16);
}

.layout-card figcaption {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: start;
  margin-top: 10px;
  font-size: 0.85rem;
  line-height: 1.25;
}

.layout-card figcaption span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  color: var(--ivory);
  font-weight: 900;
  background: var(--navy-900);
  border-radius: 50%;
}

.layout-card figcaption strong {
  padding-top: 4px;
}

.code-panel {
  box-shadow: none;
}

.request-block {
  width: 100%;
  min-height: 205px;
  margin: 10px 0 18px;
  padding: 16px;
  color: var(--ivory);
  resize: vertical;
  background: var(--navy-900);
  border: 1px solid var(--navy-700);
  border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.feature-card {
  padding: 30px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.feature-card h3 {
  margin-bottom: 10px;
}

.feature-card p:last-child {
  margin-bottom: 0;
}

.page-intro {
  padding-top: 70px;
  padding-bottom: 48px;
  text-align: center;
}

.prose {
  font-size: 1.06rem;
}

.prose h2 {
  margin-top: 2.1em;
  font-size: clamp(1.65rem, 3vw, 2.35rem);
}

.prose h3 {
  margin-top: 1.7em;
}

.prose blockquote {
  margin: 34px 0;
  padding: 24px 26px;
  color: var(--navy-800);
  background: rgba(201, 134, 67, 0.1);
  border-left: 4px solid var(--copper);
  border-radius: 0 12px 12px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.28rem;
}

.positions-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 30px;
}

.position-card {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 14px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.57);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.position-card__number {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--ivory);
  font-weight: 900;
  background: var(--navy-900);
  border-radius: 50%;
}

.position-card h3 {
  margin-bottom: 5px;
  font-size: 1.08rem;
}

.position-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.catalog-toolbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 26px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.catalog-toolbar label {
  font-weight: 800;
}

.catalog-toolbar select {
  min-width: min(100%, 310px);
  padding: 10px 38px 10px 12px;
  color: var(--ink);
  background: #fffef9;
  border: 1px solid rgba(20, 35, 49, 0.24);
  border-radius: 10px;
}

.handbook-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.handbook-card {
  display: grid;
  grid-template-columns: 124px 1fr;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(4, 17, 31, 0.08);
}

.handbook-card > img {
  width: 100%;
  height: 100%;
  min-height: 300px;
  object-fit: cover;
}

.handbook-card__body {
  padding: 20px;
}

.handbook-card__field {
  margin-bottom: 6px;
  color: var(--copper-dark);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.handbook-card h3 {
  margin-bottom: 16px;
  font-size: 1.2rem;
}

.handbook-card h3 span {
  margin-right: 9px;
  color: var(--copper-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

.handbook-card h4 {
  margin: 15px 0 4px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.handbook-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.handbook-card__question {
  color: var(--navy-800) !important;
  font-style: italic;
}

.ai-panel {
  color: var(--ivory);
  background: var(--navy-900);
  border-color: var(--navy-700);
}

.ai-panel p {
  color: rgba(244, 236, 216, 0.76);
}

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

.legal-card {
  padding: 28px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.legal-card h2 {
  font-size: 1.65rem;
}

.site-footer {
  padding: 44px 22px;
  color: rgba(244, 236, 216, 0.78);
  background: var(--navy-950);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
  align-items: start;
}

.footer-mark {
  margin: 0 0 10px;
  color: var(--ivory);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  letter-spacing: 0.13em;
}

.footer-grid p {
  margin-bottom: 7px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 20px;
}

.footer-links a:hover {
  color: var(--ivory);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 18px;
  color: var(--navy-950);
  font-weight: 800;
  pointer-events: none;
  background: var(--ivory);
  border: 1px solid var(--copper);
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .reading-layout {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .handbook-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .brand-row {
    min-height: 220px;
    padding-top: 52px;
  }

  .brand-link {
    width: min(190px, 58vw);
  }

  .language-switcher {
    top: 12px;
    right: 12px;
  }

  .navigation-inner {
    min-height: 54px;
  }

  .menu-toggle {
    display: block;
  }

  .navigation {
    position: absolute;
    top: 54px;
    right: 12px;
    left: 12px;
    display: none;
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
    background: var(--navy-950);
    border: 1px solid rgba(244, 236, 216, 0.16);
    border-radius: 14px;
    box-shadow: var(--shadow);
  }

  .navigation.is-open {
    display: flex;
  }

  .navigation a {
    text-align: center;
  }

  .section {
    padding: 56px 16px;
  }

  .hero {
    padding-top: 65px;
    padding-bottom: 62px;
  }

  .draw-heading {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .selection-counter {
    justify-self: start;
  }

  .feature-grid,
  .positions-list,
  .legal-grid,
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .reading-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .catalog-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .catalog-toolbar select {
    width: 100%;
  }
}

@media (max-width: 470px) {
  .card-grid {
    gap: 3px;
  }

  .deck-card__face {
    border-radius: 3px;
  }

  .question-card,
  .content-card,
  .code-panel,
  .ai-panel {
    padding: 22px 18px;
  }

  .button-row .button {
    width: 100%;
  }

  .handbook-card {
    grid-template-columns: 94px 1fr;
  }

  .handbook-card > img {
    min-height: 270px;
  }

  .handbook-card__body {
    padding: 16px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
