/*
 * The hidden attribute must always win.
 *
 * Component rules such as `.btn { display: inline-flex }` and
 * `.profile-actions { display: flex }` are author rules, so they outrank the
 * user-agent `[hidden] { display: none }`. Without this, a control hidden by the
 * server or by script still renders — which is how the onboarding "Start reading"
 * button and an inapplicable "Connect this browser" action both appeared.
 */
[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
}

.wordy-content {
  flex: 1 0 auto;
}

/* Site shell -------------------------------------------------------------- */

.wordy-site-header {
  position: sticky;
  z-index: 50;
  top: 0;
}

.wordy-navbar {
  background: color-mix(in oklch, var(--bg) 96%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.wordy-navbar__inner {
  display: grid;
  width: min(100%, var(--content-width));
  min-height: 3.25rem;
  margin-inline: auto;
  padding: 0 var(--page-gutter);
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem 1.6rem;
}

.wordy-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-decoration: none;
  text-transform: uppercase;
}

.wordy-brand:hover {
  color: var(--ink);
  text-decoration: none;
}

.wordy-brand__mark {
  display: block;
  width: 0.5625rem;
  height: 0.5625rem;
  overflow: hidden;
  background: var(--accent);
  color: transparent;
  font-size: 0;
}

.wordy-navbar__links {
  display: flex;
  min-width: 0;
  margin-right: auto;
  align-items: center;
  gap: 0.125rem;
}

.wordy-nav-link {
  display: inline-flex;
  min-height: var(--control-height-sm);
  padding: 0 0.7rem;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--dim);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.wordy-nav-link:hover {
  background: var(--panel2);
  color: var(--ink);
  text-decoration: none;
}

.wordy-nav-link.active {
  background: var(--panel2);
  color: var(--ink);
  font-weight: 600;
}

.wordy-navbar__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.wordy-icon-action {
  position: relative;
  display: inline-grid;
  width: var(--control-height-sm);
  height: var(--control-height-sm);
  flex: 0 0 var(--control-height-sm);
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--dim);
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
}

.wordy-icon-action:hover,
.wordy-icon-action.active {
  border-color: var(--ink);
  background: var(--panel2);
  color: var(--ink);
  text-decoration: none;
}

/* Signing in is the primary action for a logged-out visitor, so it is a
   labelled button rather than one more icon next to the theme toggle. */
.wordy-signin {
  gap: 0.4rem;
  min-height: var(--control-height-sm);
  padding-inline: 0.7rem;
  border-color: var(--accent);
  background: var(--accent);
  color: oklch(0.18 0.01 80);
  font-weight: 600;
}

.wordy-signin:hover,
.wordy-signin:focus-visible {
  border-color: var(--accent);
  background: color-mix(in oklch, var(--accent) 90%, white);
  color: oklch(0.18 0.01 80);
  text-decoration: none;
}

/* Extension indicator ----------------------------------------------------
   One dot, four meanings. Colour alone never carries the state: the link's
   title, aria-label and visually-hidden text all say it in words, and the dot
   changes shape as well as hue so it survives a monochrome or colour-blind
   reading. */

.wordy-ext-indicator__dot {
  position: absolute;
  right: -0.22rem;
  bottom: -0.22rem;
  width: 0.5rem;
  height: 0.5rem;
  border: 1px solid var(--bg);
  border-radius: 50%;
  background: var(--dim);
}

.wordy-ext-indicator[data-state="checking"] .wordy-ext-indicator__dot {
  background: var(--line);
}

.wordy-ext-indicator[data-state="connected"] .wordy-ext-indicator__dot {
  background: var(--known);
}

.wordy-ext-indicator[data-state="verification-unavailable"] .wordy-ext-indicator__dot {
  background: var(--dim);
}

.wordy-ext-indicator[data-state="disconnected"] .wordy-ext-indicator__dot,
.wordy-ext-indicator[data-state="not-installed"] .wordy-ext-indicator__dot,
.wordy-ext-indicator[data-state="unsupported"] .wordy-ext-indicator__dot {
  border-radius: var(--radius-xs);
  background: var(--warning);
}

.wordy-ext-indicator[data-state="account-mismatch"] .wordy-ext-indicator__dot {
  border-radius: var(--radius-xs);
  background: var(--danger);
}

/* An extension that is absent or broken is the one thing worth pulling the eye
   to in an otherwise deliberately quiet header. */
.wordy-ext-indicator[data-state="not-installed"],
.wordy-ext-indicator[data-state="disconnected"],
.wordy-ext-indicator[data-state="account-mismatch"],
.wordy-ext-indicator[data-state="unsupported"] {
  border-color: var(--accent);
  color: var(--accent);
}

/* In those states the icon alone was too easy to miss, so it grows a short
   label ("Connect extension") and pulses twice every so often. The label only
   shows where the header has room for it: the two-row tablet layout and wide
   one-row desktops. On phones and narrow one-row widths the pulse stays. */
.wordy-ext-indicator__cta {
  display: none;
}

@media (min-width: 576px) and (max-width: 767.98px), (min-width: 1200px) {
  .wordy-ext-indicator[data-state="not-installed"],
  .wordy-ext-indicator[data-state="disconnected"],
  .wordy-ext-indicator[data-state="account-mismatch"],
  .wordy-ext-indicator[data-state="unsupported"] {
    display: inline-flex;
    width: auto;
    flex-basis: auto;
    padding-inline: 0.6rem 0.7rem;
    align-items: center;
    gap: 0.4rem;
    background: var(--accent-soft);
    font-weight: 600;
  }

  .wordy-ext-indicator[data-state="not-installed"] .wordy-ext-indicator__cta,
  .wordy-ext-indicator[data-state="disconnected"] .wordy-ext-indicator__cta,
  .wordy-ext-indicator[data-state="account-mismatch"] .wordy-ext-indicator__cta,
  .wordy-ext-indicator[data-state="unsupported"] .wordy-ext-indicator__cta {
    display: inline;
    font-size: 0.8125rem;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .wordy-ext-indicator[data-state="not-installed"],
  .wordy-ext-indicator[data-state="disconnected"],
  .wordy-ext-indicator[data-state="account-mismatch"],
  .wordy-ext-indicator[data-state="unsupported"] {
    animation: wordy-ext-nudge 20s ease-out 1.5s infinite;
  }

  .wordy-ext-indicator:hover,
  .wordy-ext-indicator:focus-visible {
    animation: none;
  }
}

/* Two quick pulses at the start of each 20s cycle, then still. The fill is an
   inset shadow rather than a background so every resting keyframe can clear
   it without knowing the width-dependent resting background. The pulse text
   uses the sign-in button's dark ink, which keeps contrast on the accent. */
@keyframes wordy-ext-nudge {
  0%, 5%, 10%, 100% {
    box-shadow:
      inset 0 0 0 2rem color-mix(in oklch, var(--accent) 0%, transparent),
      0 0 0 0 color-mix(in oklch, var(--accent) 0%, transparent);
    color: var(--accent);
  }
  2.5%, 7.5% {
    box-shadow:
      inset 0 0 0 2rem var(--accent),
      0 0 0 0.3rem color-mix(in oklch, var(--accent) 45%, transparent);
    color: oklch(0.18 0.01 80);
  }
}

.wordy-icon-action__badge {
  position: absolute;
  top: -0.28rem;
  right: -0.28rem;
  min-width: 1.1rem;
  padding: 0.14rem 0.25rem;
  border: 1px solid var(--bg);
  border-radius: var(--radius-xs);
  background: var(--danger);
  color: white;
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  line-height: 1;
  text-align: center;
}

.footer {
  flex-shrink: 0;
}

.site-footer {
  padding: clamp(2rem, 4vw, 2.75rem) max(var(--page-gutter), env(safe-area-inset-right))
    calc(1.25rem + env(safe-area-inset-bottom))
    max(var(--page-gutter), env(safe-area-inset-left));
  background: var(--panel2);
  color: var(--dim);
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
}

.site-footer__inner,
.site-footer__bottom {
  width: min(100%, var(--content-width));
  margin-inline: auto;
}

.site-footer__inner {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) minmax(0, 2.4fr);
  gap: 2rem clamp(2rem, 5vw, 4rem);
}

.site-footer__brand {
  min-height: 0;
  margin-bottom: 0.75rem;
}

.site-footer__tagline {
  max-width: 22rem;
  margin-bottom: 1rem;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.4;
}

.site-footer__contact {
  margin-bottom: 0;
  line-height: 1.6;
}

.site-footer .site-footer__email {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin-top: 0.25rem;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.site-footer__nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem;
}

.site-footer__heading {
  margin-bottom: 0.75rem;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-footer__list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer a {
  color: var(--dim);
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--ink);
}

.site-footer__list a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.site-footer__bottom {
  margin-top: clamp(1.75rem, 4vw, 2.5rem);
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.65625rem;
  letter-spacing: 0.03em;
}

.site-footer__bottom p {
  margin: 0;
}

@media (max-width: 991.98px) {
  .site-footer__inner {
    grid-template-columns: 1fr;
  }
}

/* Landing page ------------------------------------------------------------ */

.landing-hero {
  display: grid;
  justify-items: center;
  padding: 0 0 clamp(2.5rem, 5vw, 3.5rem);
  gap: clamp(1.25rem, 2.2vw, 1.75rem);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.landing-hero__copy {
  max-width: 46rem;
}

.landing-hero__title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 4.9vw, 3.4rem);
  font-weight: 400;
  letter-spacing: -0.022em;
  line-height: 1.05;
  text-wrap: balance;
}

.landing-hero__actions {
  display: flex;
  margin-top: 1.35rem;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

/* Install-first hero -------------------------------------------------------
 *
 * The head script puts one of ws-store-{chrome,firefox,both,none} on <html>.
 * Everything below is display and emphasis off that class, so the markup can
 * carry both stores for crawlers and degrade to "offer both" with no script.
 *
 * Base state == no script == ws-store-both: both stores big, no "also for",
 * no desktop-only note. Each state below narrows that down.
 */

/* Installing is the conversion, so this is the one loud thing in the hero and
   the only element still wearing the accent. */
/* Two classes deep on purpose: components.css loads after this file, so a
   single .landing-install__store would lose to .btn-lg on source order. */
.landing-install .landing-install__store {
  min-height: 3.25rem;
  padding-inline: 1.75rem;
  gap: 0.5rem;
  font-size: 1.0625rem;
}

.landing-install__alt,
.landing-install__signin {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.9rem;
  color: var(--dim);
  font-size: 0.8125rem;
}

/* The device notes line only exists where a note shows; elsewhere it would be an
   empty line of space. */
.landing-install__alt {
  display: none;
  margin: 0.85rem 0 0;
}

.ws-store-none .landing-install__alt,
.ws-cannot-install .landing-install__alt {
  display: flex;
}

.landing-install__signin {
  margin: 0.85rem 0 0;
  align-items: baseline;
}

/* "Also for …" shares the sign-in line, set a little apart from it. */
.landing-install__other {
  margin-right: 0.6rem;
}

/* Everything under the button is an alternative, not a second call to action:
   underlined dim text, so the accent is not competing with itself. */
.landing-install__alt a,
.landing-install__signin a {
  color: var(--dim);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.landing-install__alt a:hover,
.landing-install__signin a:hover {
  color: var(--accent);
}

.landing-install__other,
.landing-install__device-note,
.landing-install__more {
  display: none;
}

/* One store is the reader's: the other steps down to a plain link. */
.ws-store-chrome .landing-install__store--firefox,
.ws-store-firefox .landing-install__store--chrome {
  display: none;
}

.ws-store-chrome .landing-install__other--firefox,
.ws-store-firefox .landing-install__other--chrome {
  display: inline;
}

/* There is no safe direct-store action when the browser is known not to support
   WordySpot or when a mobile browser exposes an ambiguous Chrome/Safari identity.
   Creating the account becomes the action and the matching explanation is shown. */
/* .landing-hero__actions is also the final CTA's button row in index.mustache,
   so this has to name the install block or that section loses its buttons. */
.ws-store-none .landing-install,
.ws-store-none .landing-install__signin-prefix {
  display: none;
}

/* A phone with no store to offer is told which browsers work on it; a desktop browser
   that cannot install (Safari) keeps both store buttons and says why. */
.ws-os-ios.ws-store-none .landing-install__device-note--ios,
.ws-os-android.ws-store-none .landing-install__device-note--android,
.ws-os-desktop.ws-cannot-install .landing-install__device-note--desktop {
  display: inline;
}

/* With no store to offer, the account is made here rather than during setup. */
.ws-store-none .landing-install__more {
  display: inline;
}

.ws-store-none .landing-install__alt {
  margin-top: 1.35rem;
}

/* Stacked, so the promoted button is never a run-in inside a sentence. */
.ws-store-none .landing-install__signin {
  flex-direction: column;
  margin-top: 1.1rem;
  align-items: center;
  gap: 0.7rem;
}

.ws-store-none .landing-hero__signin {
  display: inline-flex;
  min-height: 3.25rem;
  padding: 0 1.75rem;
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: oklch(0.18 0.01 80);
  font-size: 1.0625rem;
  font-weight: 600;
  text-decoration: none;
}

.ws-store-none .landing-hero__signin:hover {
  background: color-mix(in oklch, var(--accent) 90%, white);
  color: oklch(0.18 0.01 80);
}

.landing-word-list,
.landing-collections {
  padding-block: clamp(3rem, 7vw, 3.5rem);
  border-bottom: 1px solid var(--line);
}

.landing-cta {
  display: grid;
  justify-items: center;
  padding-block: clamp(3rem, 7vw, 4rem);
  text-align: center;
}

.landing-cta h2 {
  max-width: 22ch;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4vw, 2.25rem);
  font-weight: 400;
  letter-spacing: -0.015em;
}

.landing-cta p {
  max-width: 40rem;
  margin: 0.9rem 0 0;
  color: var(--dim);
  font-size: 0.9375rem;
  line-height: 1.62;
}

/* Sits after the buttons: an answer to "who is behind this?", asked only once
   the pitch has landed. */
.landing-cta .landing-cta__note {
  max-width: 34rem;
  margin: 1.35rem 0 0;
  color: var(--dim);
  font-size: 0.8125rem;
}

.landing-section-heading {
  max-width: 45rem;
  margin-bottom: 1.5rem;
}

.landing-section-heading h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4vw, 2rem);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.landing-section-heading > p:last-child {
  margin: 0.5rem 0 0;
  color: var(--dim);
  font-size: 0.875rem;
}

.landing-capability__icon {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 1rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  color: var(--accent);
  font-size: 1.05rem;
}

.word-scroller {
  padding: 1rem;
  overflow-x: auto;
}

.word-scroller-header {
  display: flex;
  margin-bottom: 1rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.word-scroller-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0.35rem;
  color: var(--ink);
  font-size: 0.875rem;
}

.word-scroller-table td {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: transparent;
  overflow-wrap: anywhere;
}

.word-scroller-count-badge {
  display: inline-flex;
  padding: 0.3rem 0.55rem;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--known);
  border-radius: var(--radius-xs);
  color: var(--known);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}

/* Signed-out nudge and signed-in next step ------------------------------- */

.signup-nudge,
.home-next-step {
  display: flex;
  margin-bottom: 1.5rem;
  padding: 1.15rem 1.35rem;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}

.signup-nudge__copy,
.home-next-step__copy {
  min-width: min(100%, 18rem);
  flex: 1;
}

.signup-nudge h2,
.home-next-step h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
}

.signup-nudge p,
.home-next-step p {
  margin: 0.35rem 0 0;
  color: var(--dim);
  font-size: 0.875rem;
  line-height: 1.55;
}

.signup-nudge__actions,
.home-next-step__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
}

.signup-nudge__note {
  color: var(--dim);
  font-size: 0.75rem;
}

.home-next-step {
  position: relative;
  padding-right: 3rem;
}

.home-next-step__icon {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 1.05rem;
}

.extension-connection-header {
  background: var(--panel2);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.google-icon-enabled {
  color: var(--known);
}

.add-outline * {
  outline: solid 1px var(--known);
}

.add-outline input {
  outline-color: var(--danger);
}

@media (max-width: 767.98px) {
  .wordy-navbar__inner {
    min-height: auto;
    padding-top: 0.5rem;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.35rem 0.65rem;
  }

  .wordy-navbar__links {
    width: calc(100% + (var(--page-gutter) * 2));
    margin-inline: calc(var(--page-gutter) * -1);
    padding: 0.1rem var(--page-gutter) 0.4rem;
    grid-column: 1 / -1;
    grid-row: 2;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .wordy-navbar__links::-webkit-scrollbar {
    display: none;
  }

  .wordy-navbar__actions {
    gap: 0.2rem;
  }

  .wordy-icon-action,
  .theme-toggle-btn {
    min-width: 2rem;
    width: 2rem;
    min-height: 2rem;
    height: 2rem;
    padding: 0;
  }

  .wordy-nav-link {
    padding-inline: 0.65rem;
  }

  .site-footer__nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.75rem 1rem;
  }

  .landing-hero {
    padding-block: 0 2.5rem;
  }

  .landing-hero__title {
    font-size: clamp(2rem, 8.4vw, 2.75rem);
  }

  /* Full-width primary, secondary wrapping under it at its own width. */
  .landing-hero__actions .btn-primary {
    width: 100%;
  }

  /* The promoted sign-in on a phone is the primary action, so it matches. */
  .ws-store-none .landing-hero__signin {
    width: 100%;
    justify-content: center;
  }

  .word-scroller-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .landing-cta .landing-hero__actions {
    width: 100%;
  }
}

@media (max-width: 389.98px) {
  .wordy-brand__name {
    font-size: 0.6875rem;
  }

  .wordy-navbar__actions {
    gap: 0.1rem;
  }

  .wordy-nav-link {
    padding-inline: 0.55rem;
    font-size: 0.75rem;
  }
}
