/* ==========================================================================
   Battery Life — Help
   In-app help styling. Designed for WKWebView on iOS, so it follows the
   system appearance automatically and respects the device's safe areas.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens — LIGHT is the base palette
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* Surfaces, following iOS grouped-list conventions */
  --bg:           #f2f2f7;
  --card:         #ffffff;
  --card-press:   #e8e8ed;
  --separator:    rgba(60, 60, 67, 0.13);
  --hairline:     rgba(60, 60, 67, 0.29);

  /* Text */
  --text:         #1c1c1e;
  --text-muted:   #6c6c70;
  --text-dim:     #8e8e93;

  /* Brand green, from the app icon (#44f368 → #4adb64).
     The raw icon green fails contrast on white, so light mode uses a
     deepened version for anything text-sized, and keeps the bright icon
     green only for solid fills where dark ink sits on top. */
  --accent:       #12822f;
  --accent-fill:  #2fc255;
  --accent-soft:  rgba(47, 194, 85, 0.13);
  --accent-line:  rgba(47, 194, 85, 0.32);
  --accent-ink:   #04220d;

  --radius:       12px;
  --radius-lg:    16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
          Roboto, Helvetica, Arial, sans-serif;

  --pad: 16px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

/* DARK — redefines tokens only. Guarded so an explicit light choice wins. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #000000;   /* true black, like the app itself */
    --card:        #1c1c1e;
    --card-press:  #2c2c2e;
    --separator:   rgba(84, 84, 88, 0.55);
    --hairline:    rgba(84, 84, 88, 0.8);

    --text:        #f2f2f7;
    --text-muted:  #98989f;
    --text-dim:    #8e8e93;

    --accent:      #44f368;   /* the icon green reads perfectly on black */
    --accent-fill: #44e964;
    --accent-soft: rgba(68, 243, 104, 0.15);
    --accent-line: rgba(68, 243, 104, 0.3);
    --accent-ink:  #04220d;
  }
}

/* Explicit overrides, so a stamped choice beats the OS in both directions. */
:root[data-theme="dark"] {
  --bg:          #000000;
  --card:        #1c1c1e;
  --card-press:  #2c2c2e;
  --separator:   rgba(84, 84, 88, 0.55);
  --hairline:    rgba(84, 84, 88, 0.8);
  --text:        #f2f2f7;
  --text-muted:  #98989f;
  --text-dim:    #8e8e93;
  --accent:      #44f368;
  --accent-fill: #44e964;
  --accent-soft: rgba(68, 243, 104, 0.15);
  --accent-line: rgba(68, 243, 104, 0.3);
  --accent-ink:  #04220d;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  /* Explicit background: the webview paints its own ground behind the page. */
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;          /* no long-press menu inside the app */
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration: none; }
a:active { opacity: 0.6; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.022em; }
p  { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

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

/* --------------------------------------------------------------------------
   3. Layout — safe-area aware
   -------------------------------------------------------------------------- */
.page {
  max-width: 700px;
  margin-inline: auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 20px)
    calc(env(safe-area-inset-right, 0px) + var(--pad))
    calc(env(safe-area-inset-bottom, 0px) + 48px)
    calc(env(safe-area-inset-left, 0px) + var(--pad));
}

/* --------------------------------------------------------------------------
   4. Page header
   -------------------------------------------------------------------------- */
.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 12px 0 30px;
  text-align: center;
}
.masthead__icon {
  width: 74px;
  height: 74px;
  filter: drop-shadow(0 8px 20px rgba(47, 194, 85, 0.3));
}
.masthead__icon img { width: 100%; height: 100%; display: block; }
.masthead h1 {
  font-size: 27px;
  letter-spacing: -0.032em;
}
.masthead p {
  color: var(--text-muted);
  font-size: 15px;
}

/* Back bar on sub-pages */
.topbar {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 8px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: -6px;
  padding: 6px;
  color: var(--accent);
  font-size: 17px;
}
.back svg { width: 19px; height: 19px; flex: none; }
.back:active { opacity: 0.5; }

.subhead {
  padding: 6px 0 24px;
}
.subhead h1 {
  font-size: 32px;
  letter-spacing: -0.035em;
}
.subhead p {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 15px;
}

/* --------------------------------------------------------------------------
   5. Grouped list (iOS Settings style)
   -------------------------------------------------------------------------- */
.group { margin-bottom: 30px; }

.group__label {
  padding: 0 var(--pad) 7px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.list {
  background: var(--card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px var(--pad);
  color: inherit;
  transition: background 0.12s;
}
.row + .row { box-shadow: inset 0 1px 0 var(--separator); }
a.row:active { background: var(--card-press); }

.row__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-fill);
  color: var(--accent-ink);
}
.row__icon svg { width: 17px; height: 17px; }

.row__text { flex: 1; min-width: 0; }
.row__text strong { display: block; font-weight: 400; font-size: 17px; }
.row__text small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
}

.row__value {
  color: var(--text-muted);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.badge {
  flex: none;
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.chevron {
  flex: none;
  width: 9px;
  height: 15px;
  color: var(--text-dim);
  opacity: 0.7;
}

/* --------------------------------------------------------------------------
   6. Disclosure rows (<details>) — FAQ + changelog
   -------------------------------------------------------------------------- */
.disclosure { background: var(--card); }
.disclosure + .disclosure { box-shadow: inset 0 1px 0 var(--separator); }

.disclosure > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 13px var(--pad);
  cursor: pointer;
  list-style: none;
  transition: background 0.12s;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::marker { content: ""; }
.disclosure > summary:active { background: var(--card-press); }

.disclosure__title {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.018em;
}
.disclosure__meta {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
}

.disclosure__caret {
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--text-dim);
  transition: transform 0.25s var(--ease);
}
.disclosure[open] > summary .disclosure__caret { transform: rotate(90deg); }

.disclosure__body {
  padding: 2px var(--pad) 18px;
  color: var(--text-muted);
  font-size: 15.5px;
  line-height: 1.55;
  animation: reveal 0.28s var(--ease);
}
.disclosure__body > * + * { margin-top: 11px; }
.disclosure__body strong { color: var(--text); font-weight: 600; }
.disclosure__body em { font-style: normal; color: var(--text-dim); }

@keyframes reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* Bulleted content inside a disclosure */
.bullets { display: flex; flex-direction: column; gap: 9px; }
.bullets li {
  position: relative;
  padding-left: 20px;
}
.bullets li::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-fill);
}

/* A step inside an answer: bold instruction + explanatory note */
.step + .step { margin-top: 16px; }
.step h3 {
  color: var(--text);
  font-size: 15.5px;
  font-weight: 600;
}
.step p { margin-top: 4px; }

/* Deep-linked target gets a brief highlight so it's findable */
.disclosure.is-target { background: var(--accent-soft); }

/* --------------------------------------------------------------------------
   7. Footer
   -------------------------------------------------------------------------- */
.foot {
  padding: 26px var(--pad) 0;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}
.foot p + p { margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
