/* ============================================================
   The Profit Pilgrim — plain. White background, black text.
   Marked days are bold; everything else stays out of the way.
   ============================================================ */

:root {
  --bg: #fff;
  --ink: #000;
  --faint: #8f8f8f;   /* unmarked days, quiet labels — light but readable */
  --mid: #666;
  --line: #e8e8e8;
  color-scheme: light;
}
/* dark scheme: near-black ground, off-white ink — same starkness, no glow.
   The house rule generalizes: ink on ground, or ground on ink. */
:root[data-theme="dark"] {
  --bg: #111;
  --ink: #f2f2f2;
  --faint: #757575;
  --mid: #9a9a9a;
  --line: #272727;
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1.1rem 1.2rem;
  -webkit-font-smoothing: antialiased;
}

/* ---------- theme toggle: a little I/O light switch, top right ----------
   I = lights on (light scheme), O = off (dark scheme).
   The active position is filled, like a pressed rocker. */
#theme {
  position: fixed;
  top: 1rem;
  right: 1.1rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 2px solid var(--ink);
  padding: 0;
  cursor: pointer;
  width: 30px;
}
#theme span {
  display: block;
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
  text-align: center;
  padding: 0.42rem 0;
}
:root:not([data-theme="dark"]) #theme .sw-on { background: var(--ink); color: var(--bg); }
:root[data-theme="dark"] #theme .sw-off { background: var(--ink); color: var(--bg); }

/* ---------- masthead ----------
   margin-top:auto here + margin-top:auto on the footer centers the
   title+calendar group vertically in the viewport; on screens shorter
   than the content the margins collapse and it flows normally. */
header { text-align: center; margin-top: auto; margin-bottom: 2.8rem; }
h1 {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
h1 a { color: var(--ink); text-decoration: none; }

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-bottom: auto;   /* pairs with header's margin-top:auto to center the group */
}

/* ---------- calendar (home view: this is the whole site) ---------- */
#calendar { width: min(92vw, 84vh, 580px); }

.load {
  display: flex; justify-content: center; align-items: center;
  min-height: 300px;
}
.load span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink);
  animation: breathe 1.1s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.15; }
  50%      { opacity: 0.8; }
}

.cal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.6rem;
}
.cal-m {
  text-align: center;
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  margin-left: 0.18em;
  text-transform: uppercase;
}
.cal-m small {
  font-size: 0.6em;
  font-weight: 800;
  color: var(--faint);
  margin-left: 0.6em;
  letter-spacing: 0.18em;
}
.nav {
  background: none;
  border: none;
  color: var(--faint);
  font-family: inherit;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  padding: 0.4rem 0.7rem;
}
.nav:hover { color: var(--ink); }

.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.wd {
  text-align: center;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--faint);
  padding-bottom: 1rem;
}
.day {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: none;
  border: none;
  font-family: inherit;
  font-size: clamp(0.9rem, 3vw, 1.15rem);
  color: var(--faint);
}
.day.today { text-decoration: underline; text-underline-offset: 4px; }

/* marked days: bold black — the only thing that speaks.
   Only two states exist anywhere: black on white, or white on black.
   Hover and reading both invert the box fully. */
button.day {
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}
button.day:hover,
button.day.sel {
  background: var(--ink);
  color: var(--bg);
}

/* ---------- the diary page ----------
   Two views: home = calendar only; body.reading = the diary.
   Phones: page only, back link on top. Laptops: calendar docks left. */
#entry { display: none; width: min(92vw, 560px); }
body.reading #entry { display: block; }
body.reading #calendar { display: none; }

.back {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 2rem;
}
.back:hover { text-decoration: underline; text-underline-offset: 3px; }

.page-head { margin-bottom: 2rem; }
.page-dow {
  display: block;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.5rem;
}
.page-head h2 { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.01em; }
.page-head .etitle {
  display: block;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--mid);
  margin-top: 0.45rem;
}

.page-body { font-size: 1.02rem; line-height: 1.8; }
.page-body p { margin-bottom: 1.1rem; }
.page-body ul { margin: 0 0 1.1rem 1.25rem; }
.page-body li { line-height: 1.8; }
.page-body a { color: var(--ink); text-underline-offset: 3px; }
.page-body a:hover { background: var(--ink); color: var(--bg); text-decoration: none; }
.page-body a.ext { word-break: break-all; }

/* $TICKER links: bold; hover inverts, per the house rule */
a.tick {
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
}
a.tick:hover { background: var(--ink); color: var(--bg); }

/* the $ tag under the home calendar → the ticker index */
#tickers-link {
  margin-top: 2.2rem;
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--ink);
  text-decoration: none;
  padding: 0.2rem 0.9rem;
}
#tickers-link:hover { background: var(--ink); color: var(--bg); }
body.reading #tickers-link { display: none; }

/* ticker index: search box */
.ticksearch {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
  background: none;
  border: none;
  border-bottom: 2px solid var(--ink);
  padding: 0.4rem 0 0.5rem;
  margin-bottom: 1.8rem;
  outline: none;
  border-radius: 0;
}
.ticksearch::placeholder { color: var(--faint); font-weight: 700; }

/* ticker page */
.tick-name { font-size: 2rem; font-weight: 900; letter-spacing: 0.01em; }
.ticklist { list-style: none; margin: 0; }
.ticklist li { margin-bottom: 0.9rem; font-size: 1rem; }
.ticklist a {
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
}
.ticklist a:hover { background: var(--ink); color: var(--bg); }
.tl-title { color: var(--mid); margin-left: 0.5rem; }
.page-body figure { margin: 1.6rem 0; }
.page-body img { max-width: 100%; height: auto; display: block; }
.page-body figure.chart svg { width: 100%; height: auto; display: block; cursor: crosshair; }
/* charts are inlined SVG, so CSS remaps their colors to the active scheme
   (attribute selectors override the generator's presentation attributes) */
figure.chart svg rect[fill="#fff"] { fill: var(--bg); }
figure.chart svg [stroke="#000"] { stroke: var(--ink); }
figure.chart svg [fill="#000"] { fill: var(--ink); }
figure.chart svg [stroke="#eee"] { stroke: var(--line); }
figure.chart svg text[fill="#666"] { fill: var(--mid); }
figure.chart svg [stroke="#666"] { stroke: var(--mid); }
figure.chart svg .tip text[fill="#fff"] { fill: var(--bg); }
.page-body figcaption {
  margin-top: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--mid);
}
.none { color: var(--mid); line-height: 1.8; }

.enav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.8rem;
  padding-top: 1rem;
  border-top: 1px solid var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}
.enav a { color: var(--ink); text-decoration: none; }
.enav a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- reading state ----------
   Title pinned to the top; the WRITING is the centered column of the
   screen. The calendar lives in the left gutter only when it truly fits
   (wide laptops); below that it hides and the back link takes over. */
body.reading header { margin-top: 0; }

@media (min-width: 1150px) {
  body.reading main {
    display: grid;
    grid-template-columns: 1fr min(560px, 92vw) 1fr;
    column-gap: 2.5rem;
    align-items: start;
  }
  body.reading #calendar {
    display: block;
    grid-column: 1;
    justify-self: end;
    width: 270px;
    position: sticky;
    top: 1.6rem;
  }
  body.reading #entry { grid-column: 2; width: 100%; }
  body.reading .back { display: none; }
  body.reading .cal-top { margin-bottom: 1rem; }
  body.reading .cal-m { font-size: 0.95rem; }
  body.reading .nav { font-size: 1rem; padding: 0.2rem 0.5rem; }
  body.reading .wd { font-size: 0.46rem; padding-bottom: 0.5rem; }
  body.reading .day { font-size: 0.72rem; }
}

@media (prefers-reduced-motion: reduce) {
  .load span { animation: none; opacity: 0.5; }
}
