/* ============================================================
   PHMail — style.css
   Design system: privacy-tech minimal. Deep-ink surfaces, one
   cyan→indigo gradient reserved for the identity + countdown,
   monospace for anything ephemeral (addresses, timers, senders).
   No frameworks, no build step.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --bg: #f6f8fa;
  --bg-soft: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --border: #dde4ec;
  --ink: #0e141b;
  --ink-2: #46556a;
  --muted: #7b8899;
  --accent-1: #0891b2;
  --accent-2: #4f46e5;
  --accent-grad: linear-gradient(120deg, #06b6d4, #6366f1);
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --shadow-sm: 0 1px 2px rgba(14, 20, 27, .06);
  --shadow-md: 0 6px 24px -8px rgba(14, 20, 27, .14);
  --shadow-lg: 0 24px 60px -20px rgba(14, 20, 27, .25);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-h: 64px;
}

[data-theme="dark"] {
  --bg: #0b0f14;
  --bg-soft: #0e141b;
  --surface: #121821;
  --surface-2: #182130;
  --border: #223046;
  --ink: #e7edf4;
  --ink-2: #a9b7c9;
  --muted: #6d7d92;
  --accent-1: #22d3ee;
  --accent-2: #818cf8;
  --accent-grad: linear-gradient(120deg, #22d3ee, #818cf8);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 28px -10px rgba(0, 0, 0, .6);
  --shadow-lg: 0 28px 70px -24px rgba(0, 0, 0, .75);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
img, svg { vertical-align: middle; }
a { color: var(--accent-1); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
:focus-visible {
  outline: 2px solid var(--accent-1);
  outline-offset: 2px;
  border-radius: 4px;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.container { max-width: 1060px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: center; color: var(--ink); }
.brand:hover { text-decoration: none; }
.main-nav { display: flex; gap: 4px; }
.main-nav a {
  color: var(--ink-2); font-size: 14.5px; font-weight: 500;
  padding: 8px 12px; border-radius: var(--radius-sm);
}
.main-nav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-2); cursor: pointer; transition: all .15s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--muted); }
#theme-toggle .icon-moon { display: none; }
[data-theme="dark"] #theme-toggle .icon-sun { display: none; }
[data-theme="dark"] #theme-toggle .icon-moon { display: inline; }

.menu-toggle { display: none; }
.mobile-nav {
  display: none; flex-direction: column; padding: 8px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.mobile-nav a { padding: 12px 4px; color: var(--ink-2); font-weight: 500; border-bottom: 1px solid var(--border); }
.mobile-nav a:last-child { border-bottom: 0; }
.mobile-nav.open { display: flex; }

/* ---------- Hero ---------- */
.hero {
  padding: 68px 0 28px;
  text-align: center;
  position: relative;
}
.hero::before {
  content: "";
  position: absolute; inset: -120px 0 auto 0; height: 420px;
  background:
    radial-gradient(560px 240px at 30% 0%, color-mix(in srgb, var(--accent-1) 14%, transparent), transparent 70%),
    radial-gradient(560px 240px at 70% 0%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 70%);
  pointer-events: none;
}
.hero > * { position: relative; }
.hero h1 {
  font-size: clamp(2rem, 5.4vw, 3.3rem);
  line-height: 1.08; letter-spacing: -0.035em; font-weight: 750;
  margin: 0 0 14px;
}
.hero h1 .grad {
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .sub {
  color: var(--ink-2); font-size: 17px; max-width: 520px; margin: 0 auto 36px;
}

/* ---------- Email card (signature element) ---------- */
.email-card {
  max-width: 640px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 26px 26px 22px;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.email-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent-grad);
}
.email-card .eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.address-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.address {
  font-family: var(--mono);
  font-size: clamp(15px, 3.4vw, 21px);
  font-weight: 600; letter-spacing: -.01em;
  color: var(--ink);
  word-break: break-all;
  min-height: 1.4em;
  flex: 1 1 auto;
  user-select: all;
}
.address.loading { color: var(--muted); }

.card-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 10px; padding: 10px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--ink);
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent-grad); color: #08111c; border: none;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-ghost { background: transparent; }
.btn.copied { background: var(--ok); color: #fff; border-color: var(--ok); }

/* Countdown */
.expiry {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 13px; color: var(--ink-2);
}
.expiry-ring { width: 22px; height: 22px; transform: rotate(-90deg); }
.expiry-ring circle { fill: none; stroke-width: 3; }
.expiry-ring .track { stroke: var(--border); }
.expiry-ring .fill {
  stroke: url(#ring-grad);
  stroke-linecap: round;
  stroke-dasharray: 56.5;
  transition: stroke-dashoffset .9s linear;
}
.expiry.warning { color: var(--warn); }
.expiry.expired { color: var(--danger); }

/* ---------- Inbox ---------- */
.inbox-section { padding: 40px 0 64px; }
.inbox-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.inbox-head h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.count-pill {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--ink-2); border-radius: 999px; padding: 2px 10px;
}
.inbox-actions { display: flex; gap: 8px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.inbox-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Desktop table */
.msg-table { width: 100%; border-collapse: collapse; }
.msg-table th {
  text-align: left; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 12px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.msg-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.msg-table tr:last-child td { border-bottom: 0; }
.msg-row { cursor: pointer; transition: background .12s ease; }
.msg-row:hover { background: var(--surface-2); }
.msg-row.unread .col-sender, .msg-row.unread .col-subject { font-weight: 700; }
.col-sender { max-width: 220px; }
.sender-name { display: block; }
.sender-email { display: block; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.col-subject { color: var(--ink-2); }
.msg-row.unread .col-subject { color: var(--ink); }
.col-time { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
}
.msg-row.unread .status-dot { background: var(--accent-1); box-shadow: 0 0 8px var(--accent-1); }

/* Mobile cards */
.msg-cards { display: none; }
.msg-card {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--border);
  padding: 14px 16px; cursor: pointer; color: var(--ink);
}
.msg-card:last-child { border-bottom: 0; }
.msg-card:active { background: var(--surface-2); }
.msg-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.msg-card .from { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-card .when { font-family: var(--mono); font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.msg-card .subj { color: var(--ink-2); font-size: 13.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-card.unread .from::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-1); margin-right: 8px; vertical-align: 2px;
}
.msg-card.unread .subj { color: var(--ink); font-weight: 600; }

/* Empty / expired states */
.state-box { padding: 56px 24px; text-align: center; color: var(--muted); }
.state-box h3 { color: var(--ink-2); margin: 14px 0 4px; font-size: 16px; }
.state-box p { margin: 0; font-size: 14px; }
.listening {
  display: inline-flex; gap: 5px; align-items: flex-end; height: 22px;
}
.listening span {
  width: 4px; border-radius: 2px; background: var(--accent-1);
  animation: pulse-bar 1.25s ease-in-out infinite;
}
.listening span:nth-child(2) { animation-delay: .18s; background: color-mix(in srgb, var(--accent-1) 60%, var(--accent-2)); }
.listening span:nth-child(3) { animation-delay: .36s; background: var(--accent-2); }
@keyframes pulse-bar {
  0%, 100% { height: 6px; opacity: .5; }
  50% { height: 20px; opacity: 1; }
}

/* ---------- Message viewer modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 9, 14, .62);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-backdrop.open { display: flex; animation: fade-in .18s ease; }
@keyframes fade-in { from { opacity: 0; } }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: min(760px, 100%); max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: pop-in .22s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes pop-in { from { transform: translateY(14px) scale(.98); opacity: 0; } }
.modal-header {
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.modal-header h3 { margin: 0 0 8px; font-size: 17px; letter-spacing: -.01em; word-break: break-word; }
.meta-line { font-size: 13px; color: var(--ink-2); word-break: break-all; }
.meta-line .k { color: var(--muted); font-family: var(--mono); font-size: 11.5px; margin-right: 6px; }
.modal-body { overflow-y: auto; padding: 0; flex: 1; }
.msg-text {
  white-space: pre-wrap; word-break: break-word;
  font-size: 14.5px; padding: 20px; margin: 0;
  font-family: var(--sans);
}
.msg-html-frame { width: 100%; border: 0; min-height: 340px; background: #fff; display: block; }
.remote-img-bar {
  display: none; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; font-size: 13px; color: var(--ink-2);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.remote-img-bar.show { display: flex; }
.attach-list { padding: 12px 20px 4px; border-top: 1px solid var(--border); }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; margin: 0 6px 8px 0;
}
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 10px;
}

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  background: var(--ink); color: var(--bg);
  border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in .25s ease;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* Offline banner */
.offline-banner {
  display: none; text-align: center; font-size: 13.5px; font-weight: 500;
  background: var(--warn); color: #1a1206; padding: 8px 16px;
}
.offline-banner.show { display: block; }

/* ---------- How it works ---------- */
.section { padding: 64px 0; }
.section-title { text-align: center; font-size: 26px; letter-spacing: -.02em; margin: 0 0 8px; }
.section-sub { text-align: center; color: var(--ink-2); margin: 0 auto 40px; max-width: 480px; font-size: 15px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.step {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 24px;
}
.step-num {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  color: var(--accent-1); letter-spacing: .12em;
}
.step h3 { margin: 10px 0 6px; font-size: 16.5px; }
.step p { margin: 0; color: var(--ink-2); font-size: 14px; }

/* ---------- Features ---------- */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 20px;
}
.feature-icon {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent-1) 12%, var(--surface-2));
  color: var(--accent-1);
}
.feature h3 { margin: 2px 0 4px; font-size: 15px; }
.feature p { margin: 0; color: var(--ink-2); font-size: 13.5px; }

/* ---------- FAQ ---------- */
.faq-list { max-width: 720px; margin: 0 auto; }
.faq-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden;
}
.faq-item summary {
  cursor: pointer; padding: 16px 20px; font-weight: 600; font-size: 15px;
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-family: var(--mono); color: var(--muted); font-size: 18px; }
.faq-item[open] summary::after { content: "–"; }
.faq-item .a { padding: 0 20px 16px; color: var(--ink-2); font-size: 14.5px; }

/* ---------- Legal pages ---------- */
.page-body { max-width: 760px; margin: 0 auto; padding: 48px 20px 80px; }
.page-body h1 { letter-spacing: -.03em; }
.page-body h2 { margin-top: 36px; font-size: 19px; }
.page-body p, .page-body li { color: var(--ink-2); font-size: 15px; }
.legal-note {
  border: 1px solid var(--warn); border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--warn) 8%, var(--surface));
  padding: 14px 18px; font-size: 14px; color: var(--ink-2);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); padding: 28px 0 40px;
  color: var(--muted); font-size: 13.5px;
}
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 18px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--ink-2); }

/* ---------- 404 ---------- */
.notfound {
  min-height: calc(100vh - var(--header-h));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px 20px;
}
.notfound .code {
  font-family: var(--mono); font-size: clamp(4rem, 14vw, 7rem); font-weight: 700;
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1;
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .steps, .features { grid-template-columns: 1fr; }
  .main-nav { display: none; }
  .menu-toggle { display: inline-flex; }
  .msg-table { display: none; }
  .msg-cards { display: block; }
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal { width: 100%; max-height: 100vh; height: 100%; border-radius: 0; border: 0; }
  .hero { padding-top: 44px; }
  .email-card { padding: 20px 18px 18px; }
  .card-actions .btn { flex: 1 1 calc(50% - 5px); justify-content: center; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}
