/* Palanoria brand tokens — marketing / chrome. See docs/BRAND_GUIDELINES.md.
   Reader article typography remains independent (user prefs). */

:root {
  --font-brand: "Literata", Georgia, serif;
  --font-interface: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --brand-wordmark-weight: 700;
  --brand-heading-weight: 700;
  --brand-section-weight: 600;

  /* Canonical brand pigments (light). */
  --color-ink: #2a2622;
  --color-muted: #6e675e;
  --color-paper: #f3efe6;
  --color-paper-deep: #e4ddd0;
  --color-accent: #1f6f66;
  --color-accent-ink: #0f3d39;
  --color-surface: #ffffff;
  --color-surface-soft: rgba(255, 252, 247, 0.78);
  --color-surface-hover: #f1f5f4;
  --color-on-accent: #f7fffd;
  --color-border: #ebe7df;
  --color-accent-soft: #ccfbf1;
  --color-danger: #b91c1c;
  --color-danger-soft: #fee2e2;
  --color-ok: #166534;
  --color-ok-soft: #dcfce7;

  /* Semantic theme tokens — page families should consume these. */
  --page: var(--color-paper);
  --page-deep: var(--color-paper-deep);
  --surface: var(--color-surface);
  --surface-soft: var(--color-surface-soft);
  --surface-hover: var(--color-surface-hover);
  --subtle: var(--color-border);
  --border: var(--color-border);
  --ink: var(--color-ink);
  --muted: var(--color-muted);
  --brand: var(--color-accent);
  --brand-ink: var(--color-accent-ink);
  --brand-soft: var(--color-accent-soft);
  --on-brand: var(--color-on-accent);
  --danger: var(--color-danger);
  --danger-soft: var(--color-danger-soft);
  --ok: var(--color-ok);
  --ok-soft: var(--color-ok-soft);

  --logo-nav-size: 32px;
  --logo-nav-gap: 0.6rem;
  --radius-control: 8px;
  --radius-button: 10px;

  /* Shared marketing page grid — header and main share this rail. */
  --marketing-page-max: 960px;
  --marketing-page-gutter: 24px;
  --marketing-page-gutter-mobile: 16px;
  /* Centered reading column for legal / long-form marketing prose. */
  --marketing-prose-max: 720px;
  --marketing-hero-mark: 108px;
  --marketing-hero-mark-radius: 18px;
  --marketing-hero-mark-gap: 2.1rem;

  /* Legacy aliases */
  --paper: var(--color-paper);
  --paper-deep: var(--color-paper-deep);
  --accent: var(--color-accent);
  --accent-ink: var(--color-accent-ink);
  --display: var(--font-brand);
  --ui: var(--font-interface);
}

.brand-wordmark {
  font-family: var(--font-brand);
  font-weight: var(--brand-wordmark-weight);
  letter-spacing: -0.02em;
}

.brand-heading {
  font-family: var(--font-brand);
  font-weight: var(--brand-heading-weight);
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-wrap: balance;
}

.brand-section {
  font-family: var(--font-brand);
  font-weight: var(--brand-section-weight);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.interface-text {
  font-family: var(--font-interface);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--logo-nav-gap);
  text-decoration: none;
  color: var(--color-ink);
  font-family: var(--font-brand);
  font-weight: var(--brand-wordmark-weight);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-mark img {
  width: var(--logo-nav-size);
  height: var(--logo-nav-size);
  flex-shrink: 0;
  background: transparent;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 8.5rem;
  padding: 0.85rem 1.35rem;
  border-radius: var(--radius-button);
  font-family: var(--font-interface);
  font-weight: 600;
  font-size: 1.02rem;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
  background: var(--brand);
  color: var(--on-brand);
  border: none;
}

.btn-primary:hover {
  transform: translateY(-1px);
  background: var(--brand-ink);
}

.marketing-shell {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-interface);
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(31, 111, 102, 0.18), transparent 55%),
    radial-gradient(900px 600px at 100% 10%, rgba(120, 90, 50, 0.12), transparent 50%),
    linear-gradient(165deg, #f7f3ea 0%, var(--page) 45%, var(--page-deep) 100%);
  min-height: 100vh;
}

/* Flex column so the legal footer sits at the bottom on short pages. */
.marketing-layout,
.landing,
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.marketing-layout > main,
.landing > main,
.page > main {
  flex: 1 1 auto;
}

/* Auth forms share marketing page ground + header; card centers in the remainder. */
.auth-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.auth-main {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem var(--marketing-page-gutter) 2.5rem;
}
.auth-shell .auth-card {
  width: min(420px, 100%);
  padding: 0;
  background: transparent;
}

/* One shared centered page container for header + main across marketing pages. */
.marketing-page {
  width: min(
    calc(100% - (2 * var(--marketing-page-gutter))),
    var(--marketing-page-max)
  );
  margin-inline: auto;
}

.marketing-prose {
  width: min(100%, var(--marketing-prose-max));
  margin-inline: auto;
}

.marketing-shell .landing-top {
  padding: 1.1rem 0;
}

.marketing-shell .landing-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.marketing-shell .landing-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
}

.marketing-shell .nav-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--color-ink);
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-control);
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  list-style: none;
  transform: translateY(0);
  transition: transform 0.15s ease, background 0.15s ease;
}

.marketing-shell .nav-action::-webkit-details-marker {
  display: none;
}

.marketing-shell .nav-action:hover {
  transform: translateY(-1px);
  background: rgba(42, 38, 34, 0.06);
}

.marketing-shell .nav-action.is-active {
  background: rgba(42, 38, 34, 0.06);
  color: var(--color-ink);
}

.marketing-shell .nav-action:focus-visible,
.marketing-shell .nav-theme-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.marketing-shell .nav-appearance {
  position: relative;
}

.marketing-shell .nav-appearance-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 11.5rem;
  max-width: min(18rem, calc(100vw - 1.5rem));
  padding: 0.45rem;
  background: var(--color-surface);
  border: 1px solid rgba(42, 38, 34, 0.12);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(42, 38, 34, 0.1);
}

.marketing-shell .nav-appearance-heading,
.marketing-shell .nav-lang-heading {
  display: block;
  margin: 0.2rem 0.35rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.marketing-shell .nav-theme-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.45rem 0.65rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
}

.marketing-shell .nav-theme-btn .hub-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  display: inline-flex;
  opacity: 0.92;
}

.marketing-shell .nav-theme-btn .hub-icon svg,
.marketing-shell .ui-locale-trigger-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.marketing-shell .nav-theme-btn:hover,
.marketing-shell .nav-theme-btn.is-active {
  background: rgba(42, 38, 34, 0.06);
}

.marketing-shell .nav-appearance-divider {
  border: 0;
  border-top: 1px solid rgba(42, 38, 34, 0.1);
  margin: 0.35rem 0;
}

.marketing-shell .ui-locale-picker {
  position: relative;
  width: 100%;
  margin: 0 0 0.15rem;
}

.marketing-shell .ui-locale-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(42, 38, 34, 0.12);
  border-radius: 8px;
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
}

.marketing-shell .ui-locale-trigger:hover,
.marketing-shell .ui-locale-trigger:focus-visible,
.marketing-shell .ui-locale-trigger[aria-expanded="true"] {
  background: rgba(42, 38, 34, 0.06);
  outline: none;
}

.marketing-shell .ui-locale-trigger-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.marketing-shell .ui-locale-current {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marketing-shell .ui-locale-caret {
  flex-shrink: 0;
  font-size: 0.75rem;
  opacity: 0.7;
}

.marketing-shell .ui-locale-options {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 50;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  max-height: min(40vh, 14rem);
  overflow-y: auto;
  border: 1px solid rgba(42, 38, 34, 0.12);
  border-radius: 8px;
  background: var(--color-surface, #fff);
  box-shadow: 0 10px 28px rgba(48, 45, 41, 0.12);
}

.marketing-shell .ui-locale-options[hidden] {
  display: none !important;
}

.marketing-shell .ui-locale-option {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  color: var(--color-ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.marketing-shell .ui-locale-option:hover,
.marketing-shell .ui-locale-option:focus-visible {
  background: rgba(42, 38, 34, 0.06);
  outline: none;
}

.marketing-shell .ui-locale-option.is-active,
.marketing-shell .ui-locale-option[aria-selected="true"] {
  background: rgba(31, 111, 102, 0.12);
  color: var(--color-accent, #1f6f66);
}

html[data-reader-theme="sepia"] {
  --color-ink: #3b3226;
  --color-muted: #6b5f4f;
  --color-paper: #efe4cf;
  --color-paper-deep: #e7d8bc;
  --color-surface: #f7f0e2;
  --color-surface-soft: rgba(247, 240, 226, 0.9);
  --color-surface-hover: #ebe1cc;
  --color-border: #e0d3bb;
  --color-accent-soft: rgba(31, 111, 102, 0.14);
  --page: #efe4cf;
  --page-deep: #e7d8bc;
  --surface: var(--color-surface);
  --surface-hover: var(--color-surface-hover);
  --subtle: var(--color-border);
  --border: var(--color-border);
  --ink: var(--color-ink);
  --muted: var(--color-muted);
  --brand-soft: var(--color-accent-soft);
}

html[data-reader-theme="sepia"] .marketing-shell {
  /* Warm sepia page — no teal wash. */
  background: linear-gradient(180deg, #f6ecda 0%, var(--page) 42%, var(--page-deep) 100%);
  color: var(--ink);
}

html[data-reader-theme="dark"] {
  --color-ink: #e6e1d6;
  --color-muted: #a39e93;
  --color-paper: #161513;
  --color-paper-deep: #121110;
  --color-surface: #24221f;
  --color-surface-soft: rgba(36, 34, 31, 0.92);
  --color-surface-hover: #2f2c28;
  --color-border: #3a3732;
  --color-accent: #3aafa4;
  --color-accent-ink: #2a9a90;
  --color-accent-soft: rgba(58, 175, 164, 0.18);
  --color-danger-soft: rgba(185, 28, 28, 0.22);
  --color-ok-soft: rgba(22, 101, 52, 0.28);
  --page: #161513;
  --page-deep: #121110;
  --surface: var(--color-surface);
  --surface-hover: var(--color-surface-hover);
  --subtle: var(--color-border);
  --border: var(--color-border);
  --ink: var(--color-ink);
  --muted: var(--color-muted);
  --brand: var(--color-accent);
  --brand-ink: var(--color-accent-ink);
  --brand-soft: var(--color-accent-soft);
}

html[data-reader-theme="dark"],
html[data-reader-theme="dark"] body,
html[data-reader-theme="dark"] .marketing-shell {
  /* Flat neutral dark — no teal ambient glow / seam between html/body/shell. */
  background: var(--page);
  background-image: none;
  color: var(--ink);
}

html[data-reader-theme="dark"] .marketing-shell .nav-appearance-menu {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

html[data-reader-theme="dark"] .marketing-shell .nav-theme-btn {
  color: var(--ink);
}

html[data-reader-theme="dark"] .marketing-shell .nav-action:hover,
html[data-reader-theme="dark"] .marketing-shell .nav-action.is-active {
  transform: translateY(-1px);
  background: rgba(255, 252, 247, 0.08);
}

html[data-reader-theme="dark"] .marketing-shell .nav-theme-btn:hover,
html[data-reader-theme="dark"] .marketing-shell .nav-theme-btn.is-active {
  background: rgba(255, 252, 247, 0.08);
}

@media (max-width: 520px) {
  :root {
    --marketing-page-gutter: var(--marketing-page-gutter-mobile);
  }

  .marketing-shell .landing-top {
    padding: 1rem 0;
  }
}

.marketing-legal-footer {
  margin-top: auto;
  padding: 1.75rem 0 2rem;
  border-top: 1px solid var(--color-border, rgba(42, 38, 34, 0.12));
}

.marketing-legal-footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
  justify-content: center;
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--color-muted, #5c5c5c);
}

.marketing-legal-footer a {
  color: inherit;
  text-decoration: none;
}

.marketing-legal-footer a:hover,
.marketing-legal-footer a:focus-visible {
  color: var(--color-ink, #1a1a1a);
  text-decoration: underline;
  outline: none;
}

.marketing-legal-sep {
  opacity: 0.55;
  user-select: none;
}

/* Legal / Support documents — centered column, justified prose. */
.legal-main {
  padding: 1.5rem 0 3.5rem;
}

.legal-doc {
  color: var(--color-ink);
  font-size: 1.02rem;
  line-height: 1.65;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.legal-doc p {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  overflow-wrap: break-word;
}

.legal-doc > *:first-child {
  margin-top: 0;
}

.legal-doc h1 {
  margin: 0 0 0.65rem;
  font-family: var(--font-brand);
  font-weight: var(--brand-heading-weight);
  letter-spacing: -0.03em;
  line-height: 1.15;
  font-size: clamp(1.85rem, 4.5vw, 2.4rem);
  text-wrap: balance;
  text-align: left;
  color: var(--color-ink);
}

.legal-doc h2 {
  margin: 2rem 0 0.75rem;
  font-family: var(--font-brand);
  font-weight: var(--brand-section-weight);
  letter-spacing: -0.02em;
  font-size: 1.28rem;
  line-height: 1.25;
  text-align: left;
  color: var(--color-ink);
}

.legal-doc h3 {
  margin: 1.35rem 0 0.45rem;
  font-family: var(--font-interface);
  font-weight: 650;
  font-size: 1.05rem;
  text-align: left;
  color: var(--color-ink);
}

.legal-doc p,
.legal-doc ul,
.legal-doc ol,
.legal-doc table {
  margin: 0 0 1rem;
}

.legal-doc ul,
.legal-doc ol {
  padding-left: 1.25rem;
}

.legal-doc li {
  margin: 0.25rem 0;
}

.legal-doc a {
  color: var(--color-accent-ink);
}

.legal-doc a:hover,
.legal-doc a:focus-visible {
  color: var(--color-accent);
}

.legal-doc em {
  color: var(--color-muted);
  font-style: italic;
}

.legal-doc table {
  width: 100%;
  min-width: 36rem;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.legal-doc th,
.legal-doc td {
  border: 1px solid var(--color-border);
  padding: 0.55rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.legal-doc th {
  background: var(--color-surface-soft);
  font-weight: 650;
}

.legal-doc hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: 1.75rem 0;
}
