/* ============================================================
   Threads Empire — Notion-inspired theme
   Single source of truth for tokens + shared components.
   Loaded by every deployed top-level HTML page.
   Spec: openspec/changes/notion-theme-redesign/specs/visual-theme/spec.md
   ============================================================ */

/* -------- Google Material Symbols (Outlined) helper -------- */
/* Font is loaded via <link> in each page <head> for reliability. */

.te-icon,
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 1.1em;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: -0.18em;
  user-select: none;
}
.te-icon--fill { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.te-icon--sm   { font-size: .95em; }
.te-icon--lg   { font-size: 1.4em; }

/* -------- Tokens: light (default) -------- */
:root,
[data-theme="light"] {
  /* Surface */
  --bg: #ffffff;
  --bg-elev: #f7f6f3;
  --bg-overlay: rgba(15, 15, 15, 0.45);

  /* Text */
  --text: #37352f;
  --muted: #787774;
  --rule: #e9e9e7;

  /* Accent + intent (Notion orange) */
  --accent: #ea580c;
  --accent-contrast: #ffffff;
  --accent-hover: #c2410c;
  --danger: #e03e3e;
  --success: #0f7b6c;

  /* Optional brand (legacy teal) — defined but unused */
  --brand: #14b8a6;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Shadow */
  --shadow-pop: 0 14px 40px rgba(15, 15, 15, 0.10),
                0 2px 6px rgba(15, 15, 15, 0.06);

  /* Type */
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont,
               "Segoe UI Variable Display", "Segoe UI", Helvetica,
               "Apple Color Emoji", "Noto Sans Arabic", "Noto Sans Hebrew",
               Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  --font-serif: ui-sans-serif, -apple-system, BlinkMacSystemFont,
                "Segoe UI Variable Display", "Segoe UI", Helvetica,
                "Apple Color Emoji", "Noto Sans Arabic", "Noto Sans Hebrew",
                Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo,
               Consolas, monospace;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 160ms;

  color-scheme: light;
}

/* -------- Tokens: dark -------- */
[data-theme="dark"] {
  --bg: #191919;
  --bg-elev: #202020;
  --bg-overlay: rgba(0, 0, 0, 0.6);

  --text: #e6e6e4;
  --muted: #9b9a97;
  --rule: #2f2f2f;

  --accent: #ffa344;
  --accent-contrast: #2a1605;
  --accent-hover: #ffb976;
  --danger: #ff7369;
  --success: #4dab9a;

  --shadow-pop: 0 14px 40px rgba(0, 0, 0, 0.6),
                0 2px 6px rgba(0, 0, 0, 0.4);

  color-scheme: dark;
}

/* -------- Reset + base elements -------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2 {
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 0.4em;
}
h1 { font-size: clamp(2rem, 4vw + 1rem, 3.25rem); }
h2 { font-size: clamp(1.5rem, 2vw + 1rem, 2.25rem); }

h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 0.4em;
}
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }
h5 { font-size: 0.95rem; }
h6 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

p { margin: 0 0 1em; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--dur) var(--ease);
}
a:hover { color: var(--accent-hover); }

hr,
.te-rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.92em; }
code { background: var(--bg-elev); padding: 1px 5px; border-radius: var(--radius-sm); }
pre {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  overflow: auto;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

input, textarea, select, button {
  font: inherit;
  color: inherit;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="search"],
input[type="tel"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.18);
}

::selection { background: rgba(35, 131, 226, 0.25); color: inherit; }

/* -------- Layout utilities -------- */
.te-page {
  max-inline-size: 720px;
  margin-inline: auto;
  padding-inline: 24px;
}
.te-page--wide { max-inline-size: 1080px; }

/* -------- Nav -------- */
.te-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 40;
}
.te-nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--dur) var(--ease);
}
.te-nav a:hover { background: var(--bg-elev); color: var(--text); }

/* -------- Buttons -------- */
.te-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
  user-select: none;
  white-space: nowrap;
}
.te-btn:disabled,
.te-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.te-btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}
.te-btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
}

.te-btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--rule);
}
.te-btn--ghost:hover {
  background: var(--bg-elev);
  border-color: var(--rule);
  color: var(--text);
}

/* -------- Cards -------- */
.te-card {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.te-card--elev { background: var(--bg-elev); }

/* -------- Promo bar (#promoPop) -------- */
.te-promo {
  background: var(--bg-elev);
  color: var(--text);
  border-bottom: 1px solid var(--rule);
  padding: 8px 16px;
  text-align: center;
  font-size: 0.92rem;
}
.te-promo a { color: var(--accent); font-weight: 500; }

/* -------- Sticky CTA (#stickyCta) -------- */
.te-sticky-cta {
  position: fixed;
  inset-inline: 16px;
  inset-block-end: 16px;
  z-index: 35;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-inline-size: 520px;
  margin-inline: auto;
}
.te-sticky-cta__copy { flex: 1; min-inline-size: 0; }

/* -------- Modal (#subModal, #loginModal) -------- */
.te-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: var(--bg-overlay);
  padding: 16px;
}
.te-modal__dialog {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  max-inline-size: 460px;
  inline-size: 100%;
  padding: 24px 22px;
}
.te-modal__title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin: 0 0 6px;
}
.te-modal__close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.te-modal__close:hover { background: var(--bg-elev); color: var(--text); }

/* -------- Toast (#toast) -------- */
.te-toast {
  position: fixed;
  inset-block-end: 24px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 0.92rem;
  box-shadow: var(--shadow-pop);
  z-index: 80;
}

/* -------- Consent banner -------- */
.te-consent {
  position: fixed;
  inset-inline: 16px;
  inset-block-end: 16px;
  z-index: 70;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  max-inline-size: 640px;
  margin-inline: auto;
}
.te-consent__copy { flex: 1 1 240px; min-inline-size: 0; font-size: 0.92rem; }
.te-consent__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* -------- Theme toggle hint -------- */
#themeToggle {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
#themeToggle:hover { background: var(--bg-elev); }

/* -------- Forms within modals/consent get a tighter button row -------- */
.te-form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* -------- Accessibility -------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { transition: none !important; animation: none !important; }
}

/* -------- Print -------- */
@media print {
  .te-nav, .te-promo, .te-sticky-cta, .te-toast, .te-consent,
  #subModal, #loginModal { display: none !important; }
  body { background: #fff; color: #000; }
}
