/* Melo Help Center — shared stylesheet.
   Tokens mirror Melo/Shared/MeloDesignSystem.swift and ui/theme/MeloPalette.kt.
   Dark mode: prefers-color-scheme AND html[data-theme="dark"] (set by help.js from ?theme=). */

:root {
  --bg: #FBF5EE;            /* parchment50 */
  --bg-elevated: #FFFFFF;
  --text: #212121;
  --text-secondary: #5F5A55;
  --primary: #1C7C54;       /* turfGreen400 */
  --link: #146140;          /* turfGreen600 */
  --border: #E8E0D8;
  --note-bg: #EDF6EF;
  --note-border: #C6DEA4;
  --step-num-bg: #1C7C54;
  --step-num-text: #FFFFFF;
  --button-bg: #1C7C54;
  --button-text: #FFFFFF;
  --button-secondary-bg: #FFFFFF;
  --button-secondary-text: #146140;
  --shadow: 0 1px 2px rgba(33, 33, 33, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #5B4136;
    --bg-elevated: #52362B;
    --text: #FFF2DF;         /* darkCoffee50 */
    --text-secondary: #D5CBC3;
    --primary: #C6DEA4;
    --link: #73E2A7;         /* celadon200 */
    --border: #6E5347;
    --note-bg: #4A3A2F;
    --note-border: #73E2A7;
    --step-num-bg: #73E2A7;
    --step-num-text: #042A17;
    --button-bg: #73E2A7;
    --button-text: #042A17;
    --button-secondary-bg: #52362B;
    --button-secondary-text: #73E2A7;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  --bg: #5B4136;
  --bg-elevated: #52362B;
  --text: #FFF2DF;
  --text-secondary: #D5CBC3;
  --primary: #C6DEA4;
  --link: #73E2A7;
  --border: #6E5347;
  --note-bg: #4A3A2F;
  --note-border: #73E2A7;
  --step-num-bg: #73E2A7;
  --step-num-text: #042A17;
  --button-bg: #73E2A7;
  --button-text: #042A17;
  --button-secondary-bg: #52362B;
  --button-secondary-text: #73E2A7;
  --shadow: none;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Lexend", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}

a { color: var(--link); }

img, video { max-width: 100%; height: auto; display: block; border-radius: 12px; }

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

/* Site header: shown only when the page is opened outside the app (help.js). */
.site-header { display: none; align-items: center; gap: 10px; padding: 8px 0 20px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.site-header a { color: var(--text); text-decoration: none; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.site-header .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); display: inline-block; }
.site-header .crumb { color: var(--text-secondary); font-size: 14px; margin-left: auto; }
html[data-embedded="false"] .site-header { display: flex; }

h1 { font-size: 24px; font-weight: 500; line-height: 1.25; margin: 4px 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 500; margin: 28px 0 8px; }
h3 { font-size: 16px; font-weight: 500; margin: 20px 0 6px; }
p { margin: 0 0 12px; }
.lede { color: var(--text-secondary); font-size: 17px; margin-bottom: 20px; }
.meta { color: var(--text-secondary); font-size: 13px; margin-bottom: 20px; }

/* Numbered steps */
ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 16px; }
ol.steps > li { counter-increment: step; position: relative; padding-left: 44px; margin-bottom: 16px; }
ol.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--step-num-bg); color: var(--step-num-text);
  font-size: 14px; font-weight: 500; display: flex; align-items: center; justify-content: center;
}
ol.steps > li > strong { display: block; margin-bottom: 2px; }
ol.steps figure { margin: 10px 0 0; }
ol.steps figcaption { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }

ul { padding-left: 20px; margin: 0 0 12px; }
li { margin-bottom: 6px; }

/* Platform-specific sections. help.js hides the other platform when ?platform= is set. */
/* Any element can carry data-platform; sections additionally get a heading on the web. */
section[data-platform] > .platform-heading { display: none; }
html[data-embedded="false"] section[data-platform] > .platform-heading { display: block; }
html[data-platform="ios"] [data-platform="android"],
html[data-platform="android"] [data-platform="ios"] { display: none !important; }

/* Callouts */
.note {
  background: var(--note-bg);
  border-left: 3px solid var(--note-border);
  padding: 12px 14px;
  border-radius: 10px;
  margin: 16px 0;
  font-size: 15px;
}
.note strong { font-weight: 500; }

/* Cards on the index */
.card-list { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 12px; }
.wrap > h2 + .card-list { margin-top: 10px; }
.card {
  display: block; text-decoration: none; color: var(--text);
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; box-shadow: var(--shadow);
}
.card:active { opacity: 0.85; }
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card p { margin: 0; color: var(--text-secondary); font-size: 14px; }
.card .time { font-size: 13px; color: var(--text-secondary); margin-top: 8px; }

/* App actions ("Set it up now"). Only rendered inside the app; help.js hides them otherwise. */
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 8px; }
.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 18px; border-radius: 12px;
  background: var(--button-bg); color: var(--button-text);
  text-decoration: none; font-weight: 500; font-size: 15px;
}
.button.secondary { background: var(--button-secondary-bg); color: var(--button-secondary-text); border: 1px solid var(--border); }
html[data-embedded="false"] .app-only { display: none !important; }
.web-only { display: none !important; }
html[data-embedded="false"] .web-only { display: inline !important; }
html[data-embedded="false"] div.web-only, html[data-embedded="false"] p.web-only { display: block !important; }

/* Inline UI names */
kbd, .ui {
  font-family: inherit; font-weight: 500;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px; font-size: 0.95em; white-space: nowrap;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; }

footer.page-footer { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-secondary); }
footer.page-footer a { color: var(--link); }

/* App Store / Google Play links, added to every page by the build. Web only. */
.get-app { margin: 16px 0 0; font-size: 14px; color: var(--text-secondary); }
.get-app a { color: var(--link); }

/* ---------------------------------------------------------------------------
   Index: category tiles. An auto-fitting grid of illustrated shortcuts that
   jump to each section (three across on a phone, five on a wide screen).
   The art is inline SVG driven by per-tile custom properties, so it follows
   light / dark like the rest of the page.
   --------------------------------------------------------------------------- */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 10px;
  margin: 4px 0 8px;
}
.cat-tile {
  display: flex; flex-direction: column;
  text-decoration: none; color: var(--text);
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 14px; padding: 6px 6px 10px; box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.cat-tile:hover { border-color: var(--art-pop); }
.cat-tile:active { transform: scale(0.97); }
.cat-tile:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.cat-tile svg { width: 100%; height: auto; display: block; border-radius: 10px; }
.cat-label { font-size: 14px; font-weight: 500; line-height: 1.25; margin: 8px 4px 0; }
.cat-count { font-size: 12px; color: var(--text-secondary); margin: 2px 4px 0; }

/* Drawing roles */
.cat-tile .bg, .cat-tile .bg-fill { fill: var(--art-bg); }
.cat-tile .paper { fill: var(--art-paper); }
.cat-tile .pop, .cat-tile .pop-fill { fill: var(--art-pop); }
.cat-tile .ink-fill { fill: var(--art-ink); }
.cat-tile .dot { fill: var(--art-on-paper); opacity: 0.28; }
.cat-tile .ink { fill: none; stroke: var(--art-ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.cat-tile .check { fill: none; stroke: var(--art-paper); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cat-tile .ring { fill: none; stroke: var(--art-on-paper); stroke-width: 2; opacity: 0.45; }
.cat-tile .on-paper { fill: none; stroke: var(--art-on-paper); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.cat-tile .kid { fill: var(--art-kid); stroke: var(--art-bg); stroke-width: 2; }
.cat-tile .ring-strong { fill: var(--art-paper); stroke: var(--art-ink); stroke-width: 3; }

/* Tile palettes (Melo design system: turf green, celadon, tea green, faded copper, baltic blue) */
.cat-tile { --art-paper: #FFFFFF; --art-ink: #1F3B2D; --art-on-paper: #1F3B2D; --art-kid: #FFFFFF; }
.cat-capture  { --art-bg: #DDF3E6; --art-pop: #1C7C54; }
.cat-tasks    { --art-bg: #E9F2D8; --art-pop: #5E8C2A; }
.cat-planning { --art-bg: #FCE9D8; --art-pop: #C8733B; }
.cat-family   { --art-bg: #F6E3DF; --art-pop: #B4534A; }
.cat-settings { --art-bg: #DCEBF3; --art-pop: #2F6F8F; }
.cat-billing  { --art-bg: #EADFF2; --art-pop: #7A4F9E; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cat-tile { --art-paper: #FFF2DF; --art-ink: #FFF2DF; --art-on-paper: #3B2A22; --art-kid: #E7C9B5; }
  :root:not([data-theme="light"]) .cat-capture  { --art-bg: #2F4A3C; --art-pop: #73E2A7; }
  :root:not([data-theme="light"]) .cat-tasks    { --art-bg: #3F4A2C; --art-pop: #C6DEA4; }
  :root:not([data-theme="light"]) .cat-planning { --art-bg: #5A4030; --art-pop: #F0A568; }
  :root:not([data-theme="light"]) .cat-family   { --art-bg: #5A3A36; --art-pop: #F09A8E; }
  :root:not([data-theme="light"]) .cat-settings { --art-bg: #2F4654; --art-pop: #8CC7E3; }
  :root:not([data-theme="light"]) .cat-billing  { --art-bg: #45365A; --art-pop: #C6A6E8; }
  :root:not([data-theme="light"]) .cat-tile .check,
  :root:not([data-theme="light"]) .cat-tile .ring-strong { stroke: #2B2019; }
  :root:not([data-theme="light"]) .cat-tile .ring-strong { fill: none; stroke: var(--art-ink); }
}
:root[data-theme="dark"] .cat-tile { --art-paper: #FFF2DF; --art-ink: #FFF2DF; --art-on-paper: #3B2A22; --art-kid: #E7C9B5; }
:root[data-theme="dark"] .cat-capture  { --art-bg: #2F4A3C; --art-pop: #73E2A7; }
:root[data-theme="dark"] .cat-tasks    { --art-bg: #3F4A2C; --art-pop: #C6DEA4; }
:root[data-theme="dark"] .cat-planning { --art-bg: #5A4030; --art-pop: #F0A568; }
:root[data-theme="dark"] .cat-family   { --art-bg: #5A3A36; --art-pop: #F09A8E; }
:root[data-theme="dark"] .cat-settings { --art-bg: #2F4654; --art-pop: #8CC7E3; }
:root[data-theme="dark"] .cat-billing  { --art-bg: #45365A; --art-pop: #C6A6E8; }
:root[data-theme="dark"] .cat-tile .check { stroke: #2B2019; }
:root[data-theme="dark"] .cat-tile .ring-strong { fill: none; stroke: var(--art-ink); }

/* Section headings are jump targets; leave room above when scrolled to. */
.section-title { scroll-margin-top: 16px; }

/* ---------------------------------------------------------------------------
   Search box on the index page (help.js). While a query is typed, the topic
   tiles and the section lists are hidden and the matching guides are listed.
   --------------------------------------------------------------------------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.help-search { margin: 0 0 20px; }
.help-search input {
  width: 100%; box-sizing: border-box; min-height: 46px; padding: 10px 14px 10px 42px;
  font: inherit; font-size: 16px; /* 16px keeps iOS from zooming on focus */
  color: var(--text); background-color: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23908880' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 13px center; background-size: 20px;
  -webkit-appearance: none; appearance: none;
}
.help-search input::placeholder { color: var(--text-secondary); }
.help-search input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
#help-search-results .count { color: var(--text-secondary); font-size: 14px; margin: 0 0 10px; }
html[data-searching="true"] .cat-grid,
html[data-searching="true"] .section-title,
html[data-searching="true"] .wrap > .card-list { display: none; }
