/* Crownlands — the public site's shared components: the layout wrap, the buttons, the header with its
   navigation and mobile menu, the theme toggle, the live-count pill and the footer. Every public page
   loads tokens.css, then this, then its own stylesheet. The markup is server/partials.js (siteHeader,
   siteFooter), so a change here or there shows on every page alike. */

/* ============ Layout ============ */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ============ Buttons ============ */
/* Primary — red cloth with a weathered gilt rule (from the KCD2 Character Creator sidebar) */
.btn-primary {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 var(--btn-pad-x); white-space: nowrap;
  font-family: var(--f-title); font-size: var(--btn-font-size); font-weight: 700; letter-spacing: var(--btn-tracking);
  color: var(--btn-on-red); text-decoration: none;
  text-shadow: 0 1px 2px rgba(20, 4, 2, .7);
  background: var(--btn-cloth), linear-gradient(to bottom, var(--btn-red), var(--btn-red-deep));
  box-shadow: 0 2px 4px rgba(0, 0, 0, .35);
  border: 0; cursor: pointer;
  transition: filter var(--dur-s) var(--ease-out), transform var(--dur-s) var(--ease-out);
}
.btn-primary::after { /* the solid gold rule */
  content: ""; position: absolute; inset: var(--btn-rule-inset); pointer-events: none;
  border: 1px solid var(--btn-rule-color);
}
.btn-primary:active { filter: brightness(.92); transform: translateY(1px); }
@media (hover: hover) { .btn-primary:hover { filter: brightness(1.12); } }

/* Secondary — gilt ghost: a transparent face with a crisp gilt outline, a faint gilt wash on hover */
.btn-secondary {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 var(--btn-pad-x); white-space: nowrap;
  font-family: var(--f-title); font-size: var(--btn-font-size); font-weight: 700; letter-spacing: var(--btn-tracking);
  color: #fff; text-decoration: none; text-shadow: 0 1px 8px rgba(0, 0, 0, .55);
  background: transparent; border: 1.5px solid var(--btn-rule-color); cursor: pointer;
  transition: background var(--dur-s) var(--ease-out), filter var(--dur-s) var(--ease-out), transform var(--dur-s) var(--ease-out);
}
.btn-secondary:active { filter: brightness(.9); transform: translateY(1px); }
@media (hover: hover) { .btn-secondary:hover { background: color-mix(in oklab, var(--btn-rule-color) 14%, transparent); } }

/* Tertiary — a quiet text button, the same height, its arrow slides on hover */
.btn-tertiary {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px;
  font-family: var(--f-title); font-size: var(--t-sm); font-weight: 600; letter-spacing: .04em;
  color: var(--bone); text-decoration: none;
  transition: color var(--dur-s) var(--ease-out);
}
.btn-tertiary::after { content: "\2192"; display: inline-block; transition: transform var(--dur-s) var(--ease-out), color var(--dur-s) var(--ease-out); }
@media (hover: hover) {
  .btn-tertiary:hover { color: var(--btn-red); }
  .btn-tertiary:hover::after { transform: translateX(5px); color: var(--gold-hi); }
}

/* ============ Header ============
   Fixed over the page's hero, transparent until the page scrolls (common.js adds .is-scrolled).
   .site-header--solid: always dark and in the flow, for a page with no hero (the map). */
.site-header {
  position: fixed; inset-inline: 0; top: 0; z-index: 50; height: var(--header-h);
  border-bottom: 1px solid transparent;
  transition: background var(--dur-m) var(--ease-out), border-color var(--dur-m) var(--ease-out);
}
.site-header.is-scrolled,
.site-header--solid {
  background: rgba(20, 18, 15, .88); backdrop-filter: blur(10px);
  border-bottom-color: var(--border);
}
.site-header.is-scrolled::after,
.site-header--solid::after { /* the single gilt hairline under the header */
  content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 164, 92, .4), transparent);
}
.site-header--solid { position: relative; z-index: 1000; background: rgb(20, 18, 15); backdrop-filter: none; border-bottom-color: rgba(201, 164, 92, .35); }
.site-header.menu-open { background: rgba(20, 18, 15, .97); border-bottom-color: var(--border); }
.site-header > .wrap { height: 100%; display: flex; align-items: center; gap: var(--s3); }

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-height: 44px; flex: none; }
.brand-icon { width: 38px; height: 38px; flex: none; }
.brand-wordmark { width: auto; height: 40px; flex: none; }

.site-nav { display: flex; align-items: center; gap: var(--s3); margin-inline-start: auto; }
.nav-links { display: flex; align-items: center; gap: 28px; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  position: relative; font-family: var(--f-title); font-size: var(--t-sm); font-weight: 600; letter-spacing: .04em;
  color: var(--on-dark-dim); text-decoration: none; padding: 6px 0;
  transition: color var(--dur-s) var(--ease-out);
}
.nav-links a::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--gold-hi);
  transition: width var(--dur-m) var(--ease-out);
}
.nav-links a[aria-current="page"] { color: var(--on-dark); }
.nav-links a[aria-current="page"]::after { width: 100%; }
@media (hover: hover) {
  .nav-links a:hover { color: var(--on-dark); }
  .nav-links a:hover::after { width: 100%; }
}
.nav-cta { display: flex; align-items: center; gap: 14px; }

/* ============ Signed-in account menu ============
   Replaces "Sign in" in the header. The header and the menu are always dark, like the rest of the
   site chrome; only the page around them follows the theme. */
.nav-links { align-items: baseline; }   /* line every item up by its text, so the account button matches the links */
.acct { position: relative; display: inline-block; }
.acct-btn {   /* styled exactly like the nav links beside it, so the name sits on the same line */
  position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 6px 0;
  background: none; border: 0; border-radius: 0; cursor: pointer;
  color: var(--on-dark-dim); font-family: var(--f-title); font-size: var(--t-sm); font-weight: 600; letter-spacing: .04em; line-height: inherit;
  transition: color var(--dur-s) var(--ease-out);
}
.acct-btn::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--gold-hi); transition: width var(--dur-m) var(--ease-out); }
@media (hover: hover) { .acct-btn:hover { color: var(--on-dark); } .acct-btn:hover::after { width: 100%; } }
.acct-btn[aria-expanded="true"] { color: var(--on-dark); }
.acct-btn[aria-expanded="true"]::after { width: 100%; }
.acct-btn .uname { max-width: 16ch; overflow: clip; text-overflow: ellipsis; white-space: nowrap; }   /* clip, not hidden: hidden would move the baseline to the bottom edge */
.acct-btn .chev { width: 14px; height: 14px; color: var(--on-dark-dim); transition: transform var(--dur-s) var(--ease-out); }
.acct-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }

.acct-menu {
  position: absolute; top: calc(100% + 18px); right: 0; z-index: 60; width: 312px; padding: 6px 0;
  background: rgba(20, 18, 15, .98) var(--grain-dark); border: 1px solid rgba(224, 191, 120, .26); border-radius: 10px;
  box-shadow: 0 24px 48px -16px rgba(0, 0, 0, .75), 0 2px 6px rgba(0, 0, 0, .4);
  text-align: left;
}
.acct-menu[hidden] { display: none; }
.acct-menu::before { /* gilt hairline along the top, as under the scrolled header */
  content: ""; position: absolute; inset-inline: 12px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(224, 191, 120, .7), transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .acct-menu:not([hidden]) { animation: menu-in 160ms var(--ease-out); transform-origin: top right; }
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.acct-head { padding: 10px 18px 12px; border-bottom: 1px solid rgba(242, 235, 223, .1); margin-bottom: 6px; }
.acct-head .u { margin: 0; font-family: var(--f-title); font-weight: 700; font-size: 1.0625rem; letter-spacing: .03em; color: var(--on-dark); overflow-wrap: anywhere; line-height: 1.2; }

.acct-menu .item {
  display: flex; align-items: center; gap: 12px; width: calc(100% - 12px); min-height: 48px; margin: 0 6px; padding: 0 12px; border: 0; border-radius: 6px;
  background: none; cursor: pointer; white-space: nowrap;
  font-family: var(--f-title); font-size: var(--t-sm); font-weight: 600; letter-spacing: .04em; line-height: inherit;
  color: var(--on-dark-dim); text-decoration: none; outline-offset: -2px;
  transition: background var(--dur-s) var(--ease-out), color var(--dur-s) var(--ease-out);
}
.acct-menu .item:hover, .acct-menu .item:focus-visible { background: rgba(242, 235, 223, .07); color: var(--on-dark); }
.acct-menu .item .ic { width: 18px; height: 18px; flex: none; color: var(--gold-hi); }
.acct-menu .item.out .ic { color: var(--on-dark-dim); }
.acct-menu .sep { height: 1px; margin: 6px 0; background: rgba(242, 235, 223, .1); }
/* menu icons come from the site's icon set, tinted with the text colour */
.acct-menu span.ic, .m-acct span.ic { background: currentColor; -webkit-mask: var(--src) center/contain no-repeat; mask: var(--src) center/contain no-repeat; }

/* ============ Theme toggle — the round control in the header ============ */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none;
  background: transparent; border: 1px solid rgba(242, 235, 223, .22); border-radius: 999px; cursor: pointer;
  color: var(--on-dark-dim);
  transition: color var(--dur-s) var(--ease-out), border-color var(--dur-s) var(--ease-out), background var(--dur-s) var(--ease-out);
}
@media (hover: hover) { .theme-toggle:hover { color: var(--on-dark); border-color: rgba(242, 235, 223, .5); background: rgba(242, 235, 223, .07); } }
.theme-toggle svg { width: 19px; height: 19px; display: block; }
.theme-toggle img { width: 22px; height: 22px; flex: none; object-fit: contain; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ============ Mobile menu — below 768px; the same round control as the theme toggle ============ */
.menu-toggle { display: none; }
.menu-toggle .bars { position: relative; width: 18px; height: 12px; flex: none; }
.menu-toggle .bars span { position: absolute; left: 0; right: 0; height: 2px; border-radius: 2px; background: currentColor; transition: transform var(--dur-s) var(--ease-out), opacity var(--dur-s) var(--ease-out); }
.menu-toggle .bars span:nth-child(1) { top: 0; }
.menu-toggle .bars span:nth-child(2) { top: 5px; }
.menu-toggle .bars span:nth-child(3) { top: 10px; }
.menu-toggle[aria-expanded="true"] .bars span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .bars span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .bars span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }
.mobile-nav { position: absolute; inset-inline: 0; top: 100%; background: rgba(20, 18, 15, .97); border-bottom: 1px solid var(--border); box-shadow: 0 24px 40px -20px rgba(0, 0, 0, .7); }
.mobile-nav[hidden] { display: none; }
.mobile-nav::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(201, 164, 92, .4), transparent); }
.mobile-nav > .wrap { display: flex; flex-direction: column; align-items: stretch; padding-block: 8px 24px; }
.mobile-nav ul { list-style: none; margin: 0; padding: 0; width: 100%; }
.mobile-nav li + li { border-top: 1px solid rgba(242, 235, 223, .08); }
.mobile-nav li a { display: flex; align-items: center; min-height: 56px; font-family: var(--f-title); font-size: 1.0625rem; font-weight: 600; letter-spacing: .04em; color: var(--on-dark); text-decoration: none; }
.mobile-nav li a:active, .mobile-nav li a[aria-current="page"] { color: var(--gold-hi); }
.mobile-nav .mobile-cta { display: block; width: 100%; margin-top: 16px; }
.mobile-nav .mobile-cta .btn-primary { width: 100%; }
/* phones: signed in, the account sits under the site links in place of the Sign in button */
.m-acct { width: 100%; margin-top: 16px; border: 1px solid rgba(224, 191, 120, .26); border-radius: 10px; background: rgba(242, 235, 223, .03); }
.m-acct .acct-head { margin-bottom: 0; padding: 14px 16px; }
.m-acct li a, .m-acct li .out { gap: 12px; padding-inline: 16px; font-size: .9375rem; white-space: nowrap; }
.m-acct li .out {   /* Sign out is a button (it posts the sign-out form), dressed as the links above it */
  display: flex; align-items: center; width: 100%; min-height: 56px; background: none; border: 0; cursor: pointer;
  font-family: var(--f-title); font-weight: 600; letter-spacing: .04em; line-height: inherit; color: var(--on-dark-dim); text-align: left;
}
.m-acct li .out:active { color: var(--gold-hi); }
.m-acct .ic { width: 18px; height: 18px; flex: none; color: var(--gold-hi); }
.m-acct .out .ic { color: var(--on-dark-dim); }
@media (prefers-reduced-motion: no-preference) {
  .mobile-nav:not([hidden]) { animation: mnav-in 200ms var(--ease-out); }
}
@keyframes mnav-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ============ Join banner — the red arabesque call to the Discord (server/partials.js joinBanner) ============ */
.road-banner { position: relative; overflow: hidden; background: #2a0b0a url("/assets/Hero_Background-1920.webp") center / cover; border-block: 1px solid rgba(224, 191, 120, .45); }
@media (max-width: 960px) { .road-banner { background-image: url("/assets/Hero_Background-960.webp"); } }
.road-banner::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(12, 4, 4, .72), rgba(12, 4, 4, .5)); }
.road-banner .wrap { position: relative; z-index: 1; min-height: 240px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: clamp(24px, 4vw, 56px); padding-block: clamp(36px, 5vw, 60px); }
.road-banner .rb-eyebrow { font-family: var(--f-title); font-weight: 600; font-size: var(--t-xs); letter-spacing: .24em; text-transform: uppercase; color: var(--gold-hi); }
.road-banner .rb-title { font-family: var(--f-hero); font-weight: 400; font-size: clamp(2rem, 1.5rem + 2vw, 3.2rem); letter-spacing: .01em; color: var(--on-dark); line-height: .98; margin-top: 8px; text-shadow: 0 3px 20px rgba(0, 0, 0, .6); }

/* ============ Footer ============ */
.site-footer { background: var(--ink); border-top: 1px solid var(--border); padding-block: var(--s5) var(--s4); }
.footer-top { display: flex; flex-wrap: wrap; gap: var(--s4); justify-content: space-between; align-items: flex-start; }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-wordmark { width: auto; height: clamp(72px, 10vw, 120px); flex: none; filter: brightness(0) opacity(.82); }
[data-theme="dark"] .footer-wordmark { filter: none; }
.footer-nav { display: flex; flex-wrap: wrap; gap: var(--s4); }
.footer-col h4 { font-family: var(--f-title); font-weight: 600; font-size: var(--t-xs); letter-spacing: .16em; text-transform: uppercase; color: var(--faint); margin: 0 0 14px; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.footer-col a { font-size: var(--t-sm); color: var(--muted); text-decoration: none; transition: color var(--dur-s) var(--ease-out); }
@media (hover: hover) { .footer-col a:hover { color: var(--bone); } }
.footer-rule { height: 1px; background: var(--border); border: 0; margin-block: var(--s4); }
.footer-legal { font-size: var(--t-xs); line-height: 1.6; color: var(--muted); max-width: 70ch; }

/* ============ Small screens ============ */
@media (max-width: 767px) {
  .site-header .brand-wordmark { display: none; }
  .brand-icon { width: 36px; height: 36px; }
  .nav-links { display: none; }
  .menu-toggle { display: inline-flex; }
  .footer-wordmark { height: 32px; }
  .road-banner .wrap { flex-direction: column; align-items: flex-start; text-align: left; }
}
