/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --bg-alt: #f5f7fa;
  --text: #1a1a1a;
  --text-muted: #555;
  --accent: #ff6b35;
  --accent-hover: #e55a2b;
  --border: #e2e8f0;
  --card: #ffffff;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
  --bg: #0f1419;
  --bg-alt: #1a1f26;
  --text: #f0f0f0;
  --text-muted: #a0a0a0;
  --accent: #ff6b35;
  --accent-hover: #ff8555;
  --border: #2a3038;
  --card: #1a1f26;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== HEADER ========== */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  font-size: 1.1rem;
}
.theme-toggle:hover { background: var(--bg-alt); }

/* ========== MAIN ========== */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.hero {
  text-align: center;
  padding: 2rem 0 3rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.hero p {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* ========== TIMER DISPLAY ========== */
.timer-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  margin: 0 auto 3rem;
  text-align: center;
}

.timer-display {
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 1rem 0;
  color: var(--text);
}

.timer-phase {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 600;
  min-height: 1.5rem;
}

.timer-rounds {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  min-height: 1.5rem;
}

/* ========== CONTROLS ========== */
.controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.btn {
  padding: 0.85rem 1.75rem;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  min-width: 110px;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

/* ========== SETTINGS ========== */
.settings {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  text-align: left;
}

.setting-group label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.setting-group input,
.setting-group select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.setting-group input:focus,
.setting-group select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ========== PRESET GRID ========== */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
}

.preset-category {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 2rem 0 1rem;
  font-weight: 600;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.preset-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
  display: block;
}

.preset-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.preset-card .name {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.preset-card .desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ========== CONTENT (for SEO/AdSense) ========== */
.content-block {
  max-width: 720px;
  margin: 3rem auto;
  padding: 0 0.5rem;
}

.content-block h2 {
  font-size: 1.5rem;
  margin: 2rem 0 0.75rem;
  font-weight: 700;
}

.content-block h3 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
  font-weight: 600;
}

.content-block p { margin-bottom: 1rem; color: var(--text); }

.content-block ul {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}
.content-block li { margin-bottom: 0.4rem; }

/* ========== FOOTER ========== */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 3rem;
}

footer a {
  color: var(--text-muted);
  margin: 0 0.5rem;
  text-decoration: none;
}
footer a:hover { color: var(--accent); }

/* ========== RUNNING STATE ========== */
.timer-card.running .timer-display { color: var(--accent); }
.timer-card.paused .timer-display { opacity: 0.6; }

/* ========== MOBILE ========== */
@media (max-width: 600px) {
  .header-inner { padding: 0 1rem; }
  main { padding: 1rem; }
  .timer-card { padding: 2rem 1.25rem; }
  .controls .btn { flex: 1; min-width: 0; }
  .preset-grid { grid-template-columns: 1fr 1fr; }
  /* Settings inputs: drop to 2-up so labels don't squish */
  .settings { grid-template-columns: 1fr 1fr; }
  /* Hero slightly tighter on phones */
  .hero { padding: 1rem 0 2rem; }
  /* Breadcrumb shouldn't wrap into a tower */
  .breadcrumb { font-size: 0.8rem; }
  /* Embed builder iframe preview: tighter */
  #livePreview { height: 320px; }
}

/* ========== ADDITIONS (v2 — SEO build) ========== */

/* Inline body links in prose */
.content-block a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.content-block a:hover { color: var(--accent-hover); }

/* Breadcrumb */
.breadcrumb {
  max-width: 720px;
  margin: 0.5rem auto 0;
  padding: 0 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 0.4rem; opacity: 0.5; }

/* FAQ — uses native <details>/<summary> */
.faq details {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: var(--card);
}
.faq summary {
  padding: 0.9rem 1rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  position: relative;
  padding-right: 2.5rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.4rem;
  color: var(--accent);
  font-weight: 400;
  line-height: 1;
}
.faq details[open] summary::after { content: "−"; }
.faq details[open] summary { border-bottom: 1px solid var(--border); }
.faq .answer { padding: 0.9rem 1rem 1rem; color: var(--text); }
.faq .answer p { margin-bottom: 0.6rem; }
.faq .answer p:last-child { margin-bottom: 0; }

/* Related timers grid (after FAQ on preset pages) */
.related-timers {
  max-width: 720px;
  margin: 2.5rem auto 0;
}
.related-timers h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.6rem;
}

/* Ad slots — reserved space prevents CLS when AdSense activates later */
.ad-slot {
  display: block;
  margin: 1.5rem auto;
  max-width: 728px;
  text-align: center;
  /* No min-height yet — slot is empty until AdSense is added.
     When you turn on AdSense, set min-height: 90px (leaderboard) or 250px (rectangle). */
}
.ad-slot[data-format="leaderboard"] { min-height: 0; }
.ad-slot[data-format="rectangle"] { min-height: 0; }
.ad-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
  display: none; /* hidden until ads activate */
}

/* Header nav */
.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
}
.site-nav .nav-links {
  display: inline-flex;
  align-items: center;
  gap: 1.25rem;
}
.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--accent); }
@media (max-width: 600px) {
  .site-nav .nav-links { display: none; }
}

/* Scroll-margin-top: when jumping to an in-page anchor (#productivity etc.),
   the sticky header would otherwise hide the heading. This pushes the scroll
   target down by roughly the header height. */
:target,
[id] {
  scroll-margin-top: 80px;
}

/* Blog */
.post-list {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
  display: block;
}
.post-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.post-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.post-card .excerpt {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Article (blog post) layout */
.article {
  max-width: 720px;
  margin: 1rem auto 0;
  padding: 0 0.5rem;
}
.article h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}
.article .meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}
.article h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5rem 0 0.75rem;
}
.article h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
}
.article p { margin-bottom: 1rem; }
.article ul, .article ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}
.article li { margin-bottom: 0.4rem; }
.article a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.article blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0 0.5rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Embed-builder textarea */
.embed-output {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--text);
  resize: vertical;
  min-height: 100px;
}

/* Embed page (used inside iframes) */
body.embed-mode {
  display: block;
  min-height: 100vh;
  background: transparent;
}
body.embed-mode main {
  padding: 1rem;
  max-width: 100%;
}
body.embed-mode .timer-card {
  margin: 0 auto;
  max-width: 100%;
}
body.embed-mode .embed-credit {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
body.embed-mode .embed-credit a {
  color: var(--text-muted);
  text-decoration: none;
}
