/* Mobile-first app shell (Phase 2). Design system grows with later phases. */

:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #0a5c36;
  --danger: #a4262c;
  --border: #e3e3e3;
  --nav-height: 3.5rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.55;
}

/* Centre the mobile layout on large screens (plan §10) */
.content {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1rem 1rem calc(var(--nav-height) + var(--safe-bottom) + 1rem);
}

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.topbar-brand { font-weight: 700; text-decoration: none; color: var(--fg); }
.topbar-title { flex: 1; color: var(--muted); font-size: 0.95rem; }
.topbar-action { margin-left: auto; }

.bottom-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 10;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;              /* accessible touch target */
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
}
.bottom-nav-item.is-active { color: var(--accent); font-weight: 600; }
.bottom-nav-item[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }

.stack { display: flex; flex-direction: column; gap: 0.75rem; max-width: 22rem; }
.stack label { font-weight: 600; font-size: 0.9rem; }
.stack input {
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }

.alert { padding: 0.7rem 0.9rem; border-radius: 8px; }
.alert-error { background: #fdecea; color: var(--danger); }

.muted { color: var(--muted); }
.status-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Capture screen */
#typed-notes {
  width: 100%;
  padding: 0.8rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  min-height: 40vh;
}
.save-status { font-size: 0.85rem; color: var(--muted); margin: 0.5rem 0; }
.save-status-error { color: var(--danger); }

/* Dashboard */
.new-idea { margin: 1rem 0 1.5rem; }
.dash-group { margin-bottom: 1.25rem; }
.dash-group h2 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.dash-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.dash-link {
  display: block;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--fg);
}
.dash-title { display: block; font-weight: 600; }
.dash-meta { display: block; font-size: 0.8rem; margin-top: 0.15rem; }

/* Media upload list */
.media-section { margin-top: 1.5rem; }
.media-pick-label { display: inline-flex; cursor: pointer; }
.media-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.media-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.25rem 0.75rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.media-item progress { width: 100%; grid-column: 1 / -1; }
.media-name { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; grid-row: span 2; }
.capture-steps { margin: 0.75rem 0 1.25rem; padding-left: 1.2rem; font-size: 0.9rem; }
.capture-steps li { margin: 0.2rem 0; }
.alert { padding: 0.75rem 1rem; border-radius: 8px; margin: 0.75rem 0; background: #f3f3f3; }
.alert-error { background: #fdecea; color: #b3261e; }

/* Recording + source review */
.rec-controls { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.rec-partial { min-height: 1.5rem; font-style: italic; }
.source-text {
  white-space: pre-wrap;
  background: #f7f7f7;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem;
  font-family: inherit;
  font-size: 0.95rem;
}
#correction-text { width: 100%; padding: 0.8rem; font: inherit; border: 1px solid var(--border); border-radius: 8px; }

/* Structure review + primitive editor (Phase 7) */
.structure-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; }
.split-review { display: grid; gap: 1.5rem; }
@media (min-width: 900px) { .split-review { grid-template-columns: 1fr 1fr; } }
.structure-section { border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem; margin-bottom: 0.8rem; }
.structure-section input, .structure-section textarea { width: 100%; margin-bottom: 0.5rem; }
#structure-fields label { display: block; margin: 0.8rem 0 0.25rem; font-weight: 600; }
#structure-fields textarea, #structure-fields input, #structure-fields select {
  width: 100%; padding: 0.5rem; font: inherit; border: 1px solid var(--border); border-radius: 8px;
}
.block-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.8rem; }
.block-item { border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.8rem; }
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.block-type { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: #666; }
.block-controls { display: flex; gap: 0.25rem; }
.btn-small { padding: 0.15rem 0.5rem; font-size: 0.85rem; }
.block-input { width: 100%; padding: 0.5rem; font: inherit; border: 1px solid var(--border); border-radius: 8px; }
.block-level, .block-attribution { margin-top: 0.4rem; }
.block-attribution { width: 100%; padding: 0.4rem; font: inherit; border: 1px solid var(--border); border-radius: 8px; }
.block-ordered { display: inline-flex; align-items: center; gap: 0.4rem; margin-top: 0.4rem; font-size: 0.9rem; }
.editor-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; }
#editor-form label { display: block; margin: 0.8rem 0 0.25rem; font-weight: 600; }
#editor-form > input, #editor-form > textarea {
  width: 100%; padding: 0.5rem; font: inherit; border: 1px solid var(--border); border-radius: 8px;
}

/* Languages overview + English reference (Phase 8) */
.lang-grid { display: grid; gap: 1rem; }
@media (min-width: 900px) { .lang-grid { grid-template-columns: repeat(3, 1fr); } }
.lang-card { border: 1px solid var(--border); border-radius: 12px; padding: 1rem; }
.lang-meta dt { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: #666; margin-top: 0.5rem; }
.lang-meta dd { margin: 0; }
.slug-row { display: flex; gap: 0.5rem; }
.slug-input { flex: 1; padding: 0.5rem; font: inherit; border: 1px solid var(--border); border-radius: 8px; }
.lang-readiness { margin: 0.8rem 0; padding: 0.6rem 0.8rem; border-radius: 8px; background: #fff4e5; font-size: 0.9rem; }
.lang-readiness.ready { background: #e8f5e9; }
.lang-readiness ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.lang-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.en-reference { border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem; margin-bottom: 1rem; background: #f7f7f7; }
.en-reference summary { cursor: pointer; font-weight: 600; }
.en-reference blockquote { border-left: 3px solid var(--border); margin: 0.5rem 0; padding-left: 0.8rem; }

/* Narration player component (Phase 9) */
.audio-player { border: 1px solid var(--border); border-radius: 12px; padding: 0.8rem; }
.player-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.player-toggle { min-width: 2.75rem; min-height: 2.75rem; }
.player-seek { flex: 1; min-width: 8rem; accent-color: #333; }
.player-time { font-variant-numeric: tabular-nums; font-size: 0.9rem; white-space: nowrap; }
.player-speed-label { font-size: 0.85rem; display: inline-flex; align-items: center; gap: 0.3rem; }
.player-speed { padding: 0.3rem; font: inherit; border: 1px solid var(--border); border-radius: 8px; }
.player-disclosure { margin: 0.5rem 0 0; font-size: 0.8rem; color: #666; }

/* Bottom sheet primitive (used by later phases; sheet.js drives it) */
.sheet[hidden] { display: none; }
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  border: 0;
  width: 100%;
  padding: 0;
}
.sheet-panel {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 1rem 1rem calc(1rem + var(--safe-bottom));
}

/* ---- Phase 10: public site ------------------------------------------------ */
.public-content { padding-bottom: calc(4.5rem + var(--safe-bottom)); max-width: 700px; margin: 0 auto; }
.lang-switch { display: flex; gap: 0.6rem; font-size: 0.85rem; }
.lang-switch a { color: inherit; text-decoration: none; opacity: 0.6; }
.lang-switch a.lang-current { opacity: 1; font-weight: 700; text-decoration: underline; }

.bottom-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 0.6rem 0 calc(0.6rem + var(--safe-bottom));
}
.bottom-nav a { color: inherit; text-decoration: none; font-size: 0.9rem; opacity: 0.7; padding: 0.2rem 0.6rem; }
.bottom-nav a.nav-active { opacity: 1; font-weight: 700; border-bottom: 2px solid currentColor; }

.feed-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.feed-controls input[type="search"] { flex: 1 1 12rem; padding: 0.5rem; font: inherit; border: 1px solid var(--border); border-radius: 8px; }
.feed-controls select { padding: 0.5rem; font: inherit; border: 1px solid var(--border); border-radius: 8px; }

.topic-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.8rem 0; }
.chip {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  text-decoration: none;
  color: inherit;
}
.chip-active { background: var(--accent, #1a73e8); color: #fff; border-color: transparent; }

.feed-list { list-style: none; margin: 1rem 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.feed-card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.feed-card-link { display: block; color: inherit; text-decoration: none; }
.feed-card-cover { width: 100%; height: auto; display: block; }
.feed-card-body { padding: 0.9rem 1rem; }
.feed-card-format { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.6; }
.feed-card-title { margin: 0.3rem 0; font-size: 1.15rem; }
.feed-card-excerpt { margin: 0.3rem 0; opacity: 0.85; }
.feed-card-thought { margin: 0.4rem 0; font-size: 1.2rem; font-style: italic; }
.feed-card time { font-size: 0.8rem; opacity: 0.6; }
.card-format-short_thought { background: color-mix(in srgb, var(--bg) 92%, currentColor); }
.feed-empty, .feed-search-note { opacity: 0.75; margin: 1.2rem 0; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin: 1.5rem 0; }
.pagination-status { font-size: 0.85rem; opacity: 0.7; }

.post-detail { padding: 1rem 0; }
.post-header h1 { margin: 0.4rem 0; }
.post-meta { display: flex; flex-wrap: wrap; gap: 0.8rem; font-size: 0.85rem; opacity: 0.7; }
.post-narration { margin: 1rem 0; }
.post-body { margin: 1.2rem 0; line-height: 1.65; }
.post-body blockquote { border-left: 3px solid var(--border); margin: 1rem 0; padding: 0.2rem 0 0.2rem 1rem; font-style: italic; }
.post-body blockquote footer { font-style: normal; font-size: 0.85rem; opacity: 0.7; }
.block-divider { border: 0; border-top: 1px solid var(--border); margin: 1.6rem auto; width: 50%; }
.block-image { margin: 1.2rem 0; }
.block-image img { width: 100%; height: auto; border-radius: 10px; }
.block-image figcaption, .block-video figcaption { font-size: 0.85rem; opacity: 0.7; margin-top: 0.4rem; }
.media-missing { border: 1px dashed var(--border); border-radius: 10px; padding: 1.2rem; text-align: center; opacity: 0.6; margin: 1.2rem 0; }
.block-linkcard {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin: 1.2rem 0;
  text-decoration: none;
  color: inherit;
}
.linkcard-title { display: block; font-weight: 700; }
.linkcard-desc { display: block; font-size: 0.9rem; opacity: 0.8; margin-top: 0.2rem; }
.linkcard-host { display: block; font-size: 0.78rem; opacity: 0.55; margin-top: 0.3rem; }

/* No-JS gallery: horizontal scroll list; Swiper upgrades in place */
.block-gallery { margin: 1.2rem 0; }
.gallery-track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
.gallery-slide { flex: 0 0 82%; scroll-snap-align: center; }
.gallery-slide img { width: 100%; height: auto; border-radius: 10px; }
.block-gallery.swiper-initialized .gallery-track { overflow: visible; }

.video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.post-footer { border-top: 1px solid var(--border); margin-top: 2rem; padding-top: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.share-row { display: flex; gap: 0.6rem; align-items: center; }
.post-alternates { display: flex; gap: 0.6rem; flex-wrap: wrap; font-size: 0.9rem; }
.related-list { list-style: none; padding: 0; margin: 0.5rem 0; display: flex; flex-direction: column; gap: 0.5rem; }
.related-list time { font-size: 0.8rem; opacity: 0.6; margin-left: 0.5rem; }

.topic-index { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.topic-index a { display: flex; justify-content: space-between; padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: inherit; }
.topic-count { opacity: 0.6; }
.archive-year h2 { margin: 1.2rem 0 0.4rem; }
.archive-months { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.archive-months a { display: inline-block; padding: 0.4rem 0.8rem; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: inherit; }
.text-page { line-height: 1.65; }

/* ---- Maintenance / operations screen (Phase 12) ---- */
.maintenance-page { display: grid; gap: 1rem; }
.card { background: #fff; border: 1px solid #e3e3e3; border-radius: 10px; padding: 1rem 1.1rem; }
.card h2 { margin: 0 0 .6rem; font-size: 1.05rem; }
.card h3 { margin: 1rem 0 .4rem; font-size: .95rem; }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th, .table td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid #eee; }
.notice { padding: .6rem .8rem; border-radius: 8px; background: #f2f2f2; font-size: .9rem; }
.notice-ok { background: #e7f6ea; color: #1c5e2c; }
.notice-error { background: #fdecec; color: #8f1f1f; }
.btn-danger { background: #b3261e; color: #fff; border-color: #b3261e; }
.form-inline { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.hint { color: #666; font-size: .8rem; }

@media (prefers-reduced-motion: reduce) {
  .gallery-track { scroll-behavior: auto; }
}
