/* ============================================================
   The Word Tools — page styles
   All colors are custom properties. Light is the default;
   dark applies via [data-theme="dark"] or, when the user
   hasn't chosen, via prefers-color-scheme.
   ============================================================ */

:root {
  color-scheme: light dark;

  --bg:              #f8f8f8;
  --text:            #000000;
  --muted:           #3a3a3c;
  --subtle:          #8e8e93;
  --surface:         #ffffff;
  --border:          #cccccc;
  --shadow:          0 2px 12px rgba(0, 0, 0, 0.12);

  /* fixed top-right controls */
  --control-bg:      #3a3a3c;
  --control-ink:     #ffffff;
  --control-border:  transparent;

  /* placeholder / outlined pill */
  --pill-muted-bg:   #f8f8f8;
  --pill-muted-ink:  #555555;

  /* install banner */
  --banner-btn-bg:   #000000;
  --banner-btn-ink:  #ffffff;
  --banner-dismiss:  #aaaaaa;

  /* login overlay — dark in both themes */
  --overlay-bg:      #1c1c1e;
  --overlay-text:    #f2f2f7;
  --overlay-muted:   #a1a1a6;
  --overlay-field:   #2c2c2e;
  --overlay-border:  #48484a;
  --overlay-error:   #ff8a75;
}

:root[data-theme="dark"] {
  --bg:              #121214;
  --text:            #f2f2f7;
  --muted:           #a1a1a6;
  --subtle:          #8e8e93;
  --surface:         #1c1c1e;
  --border:          #3a3a3c;
  --shadow:          0 2px 16px rgba(0, 0, 0, 0.5);

  --control-bg:      #2c2c2e;
  --control-ink:     #f2f2f7;
  --control-border:  #3a3a3c;

  --pill-muted-bg:   #121214;
  --pill-muted-ink:  #a1a1a6;

  --banner-btn-bg:   #f2f2f7;
  --banner-btn-ink:  #000000;
  --banner-dismiss:  #8e8e93;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:              #121214;
    --text:            #f2f2f7;
    --muted:           #a1a1a6;
    --subtle:          #8e8e93;
    --surface:         #1c1c1e;
    --border:          #3a3a3c;
    --shadow:          0 2px 16px rgba(0, 0, 0, 0.5);

    --control-bg:      #2c2c2e;
    --control-ink:     #f2f2f7;
    --control-border:  #3a3a3c;

    --pill-muted-bg:   #121214;
    --pill-muted-ink:  #a1a1a6;

    --banner-btn-bg:   #f2f2f7;
    --banner-btn-ink:  #000000;
    --banner-dismiss:  #8e8e93;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px 80px;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

body.overlay-open { overflow: hidden; }

h1 {
  font-family: 'Bebas Neue', sans-serif;
  /* "THEWORD.TOOLS" is ~5.2em wide in Bebas Neue; scale down so it
     never overflows narrow viewports. */
  font-size: min(120px, calc((100vw - 40px) / 5.4));
  font-weight: 400;
  line-height: 1;
  letter-spacing: 2px;
  color: var(--text);
  text-transform: uppercase;
  margin-bottom: 16px;
  text-align: center;
  max-width: 100%;
  overflow-wrap: anywhere;
}

h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 64px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
  margin: 32px 0 16px;
}

.tagline,
.page-text {
  max-width: 320px;
  text-align: center;
  font-size: 16px;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 44px;
}

/* ---------- home nav pills ---------- */
.buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 360px;
  margin-bottom: 60px;
}

.btn {
  display: block;
  width: 100%;
  padding: 16px 32px;
  border-radius: var(--tw-radius-pill);
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.85; }
.btn:focus-visible { outline: 3px solid var(--tw-focus); outline-offset: 2px; }

/* Black nav pill (Home) — becomes white-on-#2c2c2e in dark */
.btn-nav {
  display: inline-block;
  width: auto;
  background: var(--tw-nav-pill);
  color: var(--tw-nav-pill-ink);
  border: 1.5px solid var(--tw-nav-pill-border);
  font-size: 17px;
  padding: 12px 28px;
}

/* Placeholder / coming soon — outlined, page-colored */
.btn-soon {
  background: var(--pill-muted-bg);
  color: var(--pill-muted-ink);
  border: 1.5px solid var(--border);
}

.btn[aria-disabled="true"] {
  cursor: default;
  pointer-events: none;
  opacity: 0.6;
}

.page-nav {
  text-align: center;
  padding: 0 0 8px;
}

/* ---------- fixed top-right controls ---------- */
.top-controls {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 10px;
  z-index: 50;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--control-bg);
  color: var(--control-ink);
  border: 1px solid var(--control-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.2s ease, transform 0.12s ease;
}
.icon-btn:active { transform: scale(.96); }
.icon-btn:focus-visible { outline: 3px solid var(--tw-focus); outline-offset: 2px; }
.icon-btn svg { width: 20px; height: 20px; display: block; }

/* Theme toggle shows the icon of the theme you'd switch TO:
   moon while light, sun while dark. */
#theme-toggle .icon-sun { display: none; }
#theme-toggle[data-effective="dark"] .icon-sun  { display: block; }
#theme-toggle[data-effective="dark"] .icon-moon { display: none; }

/* Signed-in indicator on the profile button */
body.is-authed #auth-open { box-shadow: inset 0 0 0 2px var(--tw-accent); }

/* ---------- login overlay (dark in both themes) ---------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  color: var(--overlay-text);
  z-index: 150;
  display: none;
  overflow-y: auto;
  padding: 80px 20px 40px;
  color-scheme: dark;
}
.auth-overlay.is-open { display: block; }

.auth-panel {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.auth-title {
  font-family: 'Bebas Neue', sans-serif;
  font-weight: 400;
  font-size: 64px;
  line-height: 1;
  letter-spacing: 2px;
  color: var(--tw-accent);
  text-align: center;
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.auth-subtitle {
  text-align: center;
  font-size: 15px;
  line-height: 1.4;
  color: var(--overlay-muted);
  margin-bottom: 28px;
}

.auth-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--overlay-field);
  color: var(--overlay-text);
  border: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.auth-close:focus-visible { outline: 3px solid var(--tw-focus); outline-offset: 2px; }

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#auth-form[hidden] { display: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.auth-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  color: var(--overlay-text);
  background: var(--overlay-field);
  border: 1.5px solid var(--overlay-border);
  border-radius: var(--tw-radius);
}
.auth-input::placeholder { color: var(--overlay-muted); }
.auth-input:focus { outline: none; border-color: var(--tw-accent); }

.auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.auth-btn-primary,
.auth-btn-secondary {
  width: 100%;
  padding: 15px 18px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  border-radius: var(--tw-radius-pill);
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.12s ease;
}
.auth-btn-primary {
  background: var(--tw-accent);
  color: #08301F;
  border: 1.5px solid var(--tw-accent);
}
.auth-btn-secondary {
  background: transparent;
  color: var(--overlay-text);
  border: 1.5px solid var(--overlay-border);
}
.auth-btn-primary:active,
.auth-btn-secondary:active { transform: scale(.97); }
.auth-btn-primary:focus-visible,
.auth-btn-secondary:focus-visible,
.auth-forgot-btn:focus-visible { outline: 3px solid var(--tw-focus); outline-offset: 2px; }
.auth-btn-primary[disabled],
.auth-btn-secondary[disabled],
.auth-forgot-btn[disabled] { opacity: 0.5; cursor: default; }

.auth-forgot-btn {
  background: none;
  border: none;
  color: var(--overlay-muted);
  font-size: 15px;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
  margin: 4px auto 0;
}

.auth-message {
  min-height: 1.4em;
  margin-top: 16px;
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
  color: var(--overlay-muted);
}
.auth-message.is-error { color: var(--overlay-error); }
.auth-message.is-success { color: var(--tw-accent); }

.auth-signed-in {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
}
.auth-signed-in[hidden] { display: none; }
.auth-signed-in p { color: var(--overlay-muted); font-size: 15px; line-height: 1.4; }
#auth-user-email { color: var(--overlay-text); font-weight: 600; word-break: break-all; }

/* ---------- auth feedback toasts ---------- */
.auth-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 13px 22px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  z-index: 200;
  white-space: nowrap;
  pointer-events: none;
  animation: authToastIn 4s ease forwards;
}
.auth-toast-error {
  background: #b91c1c;
  white-space: normal;
  max-width: min(340px, calc(100vw - 40px));
  text-align: center;
  padding-right: 38px;
  pointer-events: auto;
  animation: authToastInStay 0.2s ease forwards;
}
.auth-toast-close {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
@keyframes authToastIn {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  12%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  80%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}
@keyframes authToastInStay {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- PWA install banner ---------- */
#install-banner {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  box-shadow: var(--shadow);
  width: max-content;
  max-width: calc(100% - 32px);
  z-index: 100;
}
#install-btn {
  background: var(--banner-btn-bg);
  color: var(--banner-btn-ink);
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
#install-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--banner-dismiss);
  font-size: 18px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

/* ---------- footer ---------- */
footer {
  margin-top: 48px;
  text-align: center;
  font-size: 13px;
  color: var(--subtle);
  padding: 0 20px;
}
footer a { color: var(--subtle); text-decoration: underline; display: inline-block; padding: 6px 4px; margin: -6px 0; }

/* ---------- mobile ---------- */
@media (max-width: 480px) {
  body { padding: 60px 16px 80px; }
  h1 { font-size: min(82px, calc((100vw - 32px) / 5.2)); letter-spacing: -1px; margin-bottom: 16px; }
  h2 { font-size: 52px; }
  .btn { font-size: 16px; padding: 14px 28px; }
  .top-controls { top: 12px; right: 16px; }
  .auth-overlay { padding: 72px 16px 32px; }
  .auth-title { font-size: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  body, .icon-btn, .btn, .auth-btn-primary, .auth-btn-secondary { transition: none; }
  .auth-toast, .auth-toast-error { animation: none; }
}
