/* ============================================================================
   Ocufolio shared stylesheet - the single source of truth for site styling.
   Every page links this file; pages add only their own structural bits inline.

   DESIGN PHILOSOPHY (from "FRONTEND DESIGN STYLE" in Ocufolio Description.txt):
     - Minimalist, heavy use of Times New Roman serif.
     - Old-web / 2005-esque, pre-heavy-CSS feel. Snappy and fast.
     - NO rounded corners (border-radius is 0 everywhere).
     - NO drop shadows, no gradients, no animations/transitions.
   Keep these rules when adding pages or components. If you reach for a shadow,
   a rounded corner, or a sans-serif font, you are off-style.
   ========================================================================== */

:root {
  --green: #2ea44f;        /* brand / positive / primary action */
  --green-dark: #1f7a38;   /* button borders + hover */
  --red: #cc2027;          /* negative / errors */
  --ink: #000;             /* body text - pure black on white, old-web style */
  --muted: #555;           /* secondary text */
  --rule: #000;            /* hairline rules and table borders */
  --rule-soft: #999;       /* lighter dividers */
  --feed-hover: #2ea44f;   /* feed card hover outline (overridden per theme) */
  --bg: #fff;              /* page background (overridden per theme) */
  /* Already-read article titles. Purple is the old-web convention for a visited
     link, which suits this site's 2005-esque brief and - unlike --muted, which
     is only a hair off --ink on a bold serif title - is unmistakable at a
     glance. Overridden per theme so it stays legible on every background. */
  --seen: #6b4c8a;
}

* { box-sizing: border-box; }

body {
  font-family: "Times New Roman", Times, serif;
  color: var(--ink);
  background: var(--bg);
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
  max-width: 60rem;
  line-height: 1.4;
  font-size: 18px;
}

/* Narrower body for single-column form pages. */
body.form-page { max-width: 30rem; }

h1, h2, h3 { font-weight: bold; margin: 0 0 .6rem; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

p { margin: .5rem 0; }

a { color: var(--green-dark); text-decoration: underline; }
a:hover { color: var(--green); }

/* Plain horizontal rule - the classic section separator. */
hr { border: 0; border-top: 1px solid var(--rule); margin: 1.5rem 0; }

/* ---- Site masthead / nav -------------------------------------------------- */
.masthead {
  display: flex; align-items: center; gap: 1.25rem;
  border-bottom: 2px solid var(--rule);
  padding-bottom: .6rem; margin-bottom: 1.5rem;
}
.masthead .brand {
  font-size: 1.6rem; font-weight: bold; letter-spacing: .02em;
  color: var(--ink); text-decoration: none;
}
.masthead .spacer { margin-left: auto; }
.masthead .navlinks { display: flex; gap: 1rem; align-items: center; font-size: .95rem; }
.masthead .navlinks a { color: var(--green-dark); }

/* ---- Buttons (square, flat, bordered - no radius, no shadow) -------------- */
.btn {
  display: inline-block;
  font-family: "Times New Roman", Times, serif;
  font-size: 1rem; font-weight: bold;
  border: 2px solid var(--green-dark);
  background: var(--green); color: #fff;
  padding: .55rem 1.5rem;
  cursor: pointer; text-decoration: none; text-align: center;
  border-radius: 0;            /* never round */
}
.btn:hover { background: var(--green-dark); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }

/* Secondary / outline button. The profile JS emits class "btn outline". */
.btn.outline, .btn.secondary {
  background: #fff; color: var(--green-dark);
}
.btn.outline:hover, .btn.secondary:hover { background: #eef7f0; color: var(--green-dark); }

/* "Following" state button (profile page). */
.btn.following { background: #eee; color: #333; border-color: #999; }

.btn.big { font-size: 1.4rem; padding: .9rem 2rem; }
.btn.block { display: block; width: 100%; }

/* ---- Form controls -------------------------------------------------------- */
label { display: block; font-weight: bold; margin: 1rem 0 .3rem; }

input, select, textarea {
  width: 100%;
  font-family: "Times New Roman", Times, serif;
  font-size: 1rem;
  padding: .5rem .55rem;
  border: 1px solid var(--ink);
  border-radius: 0;            /* square inputs */
  background: #fff; color: var(--ink);
}
input[type="checkbox"], input[type="radio"] { width: auto; }

.checkrow {
  display: flex; align-items: center; gap: .5rem;
  font-weight: normal; margin-top: .6rem; cursor: pointer;
}

/* ---- Status / message boxes (square, bordered, no shadow) ----------------- */
#msg, .msg { margin-top: 1rem; padding: .6rem .8rem; border: 1px solid; display: none; }
#msg.ok, .msg.ok   { display: block; background: #eef7f0; border-color: var(--green-dark); color: #137333; }
#msg.err, .msg.err { display: block; background: #fbecec; border-color: var(--red); color: #b3261e; }

/* Empty/placeholder panels - dashed box, the old "nothing here yet" look. */
.empty {
  color: var(--muted); text-align: center; padding: 2rem 1rem;
  border: 1px dashed var(--rule-soft);
}

/* ---- Tables --------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; margin-top: .5rem; }
th, td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--rule-soft); }
th { font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.amount { font-variant-numeric: tabular-nums; }

/* ---- Up / down coloring (shared by profile + feed) ------------------------ */
.up { color: var(--green); }
.down { color: var(--red); }

.muted { color: var(--muted); }
.center { text-align: center; }

/* Small helper text under form fields (e.g. username/display-name rules). */
.hint { color: var(--muted); font-size: .9rem; margin: .2rem 0 0; }

/* ============================================================================
   THEMES (the "Theme" web setting). theme.js sets <html data-theme="..."> from
   the user's saved preference (cached in localStorage). Default/"light" needs no
   attribute. Themes only re-point the design tokens + the page background, so the
   whole serif/flat/no-shadow system carries over unchanged.
   ========================================================================== */

/* Sepia - warm paper, like an old book. */
html[data-theme="sepia"] {
  --ink: #3b2f2f; --muted: #6b5d4f; --rule: #6b5d4f; --rule-soft: #b9a98f;
  --feed-hover: #a8642b;   /* warm amber outline on hover */
  --bg: #f4ecd8;
  --seen: #7a4f6d;         /* faded plum - reads as "read" against warm paper */
}
html[data-theme="sepia"] body { background: var(--bg); }

/* High contrast - black background, bright text, for accessibility. */
html[data-theme="high_contrast"] {
  --ink: #fff; --muted: #d8d8d8; --rule: #fff; --rule-soft: #fff;
  --green: #00d000; --green-dark: #00a000; --red: #ff6161;
  --feed-hover: #ffd400;   /* bright yellow outline on hover */
  --bg: #000;
  --seen: #c58fff;         /* light purple - distinct from both #fff ink and the yellow links */
}
html[data-theme="high_contrast"] body { background: var(--bg); }
html[data-theme="high_contrast"] a { color: #ffd400; }
html[data-theme="high_contrast"] input,
html[data-theme="high_contrast"] select,
html[data-theme="high_contrast"] textarea { background: #000; color: #fff; }

/* Several controls hardcode a white background with var(--ink) text; under high
   contrast --ink is white, so that text would be white-on-white (invisible).
   Repaint every such "white box" control black so its text stays readable. */
html[data-theme="high_contrast"] .btn.outline,
html[data-theme="high_contrast"] .btn.secondary,
html[data-theme="high_contrast"] .btn.following,
html[data-theme="high_contrast"] .add-blocks button,
html[data-theme="high_contrast"] .block .block-head button {
  background: #000; color: #fff; border-color: #fff;
}
html[data-theme="high_contrast"] .btn.outline:hover,
html[data-theme="high_contrast"] .btn.secondary:hover,
html[data-theme="high_contrast"] .add-blocks button:hover { background: #222; color: #fff; }
/* (Tabs use the theme-aware .tabs rules - active tab tracks --bg/--ink, so no
   high-contrast-specific tab override is needed.) */
/* Status/message boxes keep light backgrounds; force dark text so they're legible. */
html[data-theme="high_contrast"] .msg.ok, html[data-theme="high_contrast"] #msg.ok,
html[data-theme="high_contrast"] .msg.err, html[data-theme="high_contrast"] #msg.err { color: #000; }
/* The leaving-site confirm modal (external_links.js). */
html[data-theme="high_contrast"] .extlink-modal .box { background: #000; color: #fff; border-color: #fff; }

/* ---- Feed / post cards (home feed + profile "Recent Research") ------------
   A single research/trade item, shown as a bordered, square, flat card. */
.post { border: 1px solid var(--rule); padding: 1rem; margin-bottom: 1.25rem; }
.post .kind {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: .35rem;
}
.post h3, .post .post-title { margin: 0 0 .35rem; font-size: 1.2rem; font-weight: bold; }
.post .byline { color: var(--muted); font-size: .9rem; margin-bottom: .5rem; }
.post .prediction { font-weight: bold; margin-top: .5rem; }

/* A whole feed card that is itself a link to the article. The title is a real
   anchor whose ::after overlay stretches across the card, so the entire thumbnail
   is clickable AND keeps native right-click / ctrl-click / middle-click "open in
   new tab". Other links inside the card sit above the overlay via z-index. The
   hover outline colour is theme-dependent (--feed-hover, set per theme). */
.post-link { position: relative; }
.post-link .post-title a.stretch { color: inherit; text-decoration: none; }
.post-link .post-title a.stretch::after {
  content: ''; position: absolute; inset: 0;
}
.post-link a:not(.stretch) { position: relative; z-index: 1; }
.post-link:hover, .post-link:focus-within {
  border-color: var(--feed-hover); cursor: pointer;
}
.post-link:hover .post-title, .post-link:focus-within .post-title { color: var(--feed-hover); }
/* Once you've opened an article, its title reads back in --seen wherever it
   links from (feed cards, profile tabs, search results, embed lists) - so
   scanning back down a list after Back shows at a glance what you've read.

   .seen-post (seen_posts.js) is the mechanism: native :visited proved
   unreliable here (browsers deliberately restrict it), so seen_posts.js tracks
   opened postIDs in localStorage and paints this class on matching links after
   every render AND on bfcache restore. The :visited rules ride along as a free
   fallback. Both are listed on every selector so the two mechanisms can never
   disagree about which colour wins.

   The .post-link block needs its own, more specific selector: the card title
   sets `color: inherit` at (0,3,1), which would otherwise outrank a bare
   `a.seen-post` at (0,1,1) and leave read cards looking unread. */
a.seen-post,
a[href^="post.html?postID="]:visited { color: var(--seen); }
.post-link .post-title a.stretch.seen-post,
.post-link .post-title a.stretch:visited { color: var(--seen); }
/* Hover still wins over the read colour, so pointing at a card always gives the
   same feedback whether or not you've read it. */
.post-link:hover .post-title a.stretch.seen-post,
.post-link:focus-within .post-title a.stretch.seen-post,
.post-link:hover .post-title a.stretch:visited,
.post-link:focus-within .post-title a.stretch:visited { color: var(--feed-hover); }

/* Stock-prediction chips ("{TICKER} up/down/cruise"). */
.pred-chip {
  display: inline-block; border: 1px solid currentColor; padding: .02rem .4rem;
  margin: .1rem .25rem .1rem 0; font-size: .85rem; font-weight: bold; white-space: nowrap;
}
.pred-chip.pred-up { color: var(--green); }
.pred-chip.pred-down { color: var(--red); }
.pred-chip.pred-cruise { color: var(--muted); }

/* Article-correctness colours (the researcher-score distribution on the profile;
 * the cards themselves use the cc-icon PNGs, and the feed omits correctness).
 * Text-on-transparent, so no high_contrast repaint is needed. */
.cc-correct { color: var(--green); }
.cc-current { color: var(--green); }
.cc-incorrect { color: var(--red); }
.cc-waiting { color: var(--muted); }
.cc-deleted { color: var(--ink); }   /* deleted-articles count: plain black */

/* Trade thumbnails reuse the .post card; these are their extra bits. */
.post .trade-amount { font-size: 1.15rem; font-weight: bold; font-variant-numeric: tabular-nums; }
.post .card-actions { margin-top: .6rem; }

/* ---- Show-interest control -------------------------------------------------
   Ocufolio's like system: a checkbox ("I'm interested") with the post's public
   interest count in small font beside it. Sits inside .post cards (above the
   .post-link stretch overlay via z-index) and on the article read view.
   Text-on-transparent theme tokens only, so high_contrast needs no repaint. */
.interest-row { margin-top: .6rem; }
.interest-ctl {
  display: flex; align-items: center; gap: .45rem; cursor: pointer;
  position: relative; z-index: 1;   /* above a .post-link's stretch overlay */
  width: 100%; padding: .25rem .4rem;   /* whole row tappable, not just the checkbox - easier on mobile */
  margin: 0 -.4rem;   /* offset the padding so the row doesn't shift the layout */
  outline: 1px solid transparent;
}
.interest-ctl:hover, .interest-ctl:focus-within { outline-color: var(--ink); }
.interest-ctl input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; }
.interest-ctl .i-label { font-size: .8rem; color: var(--muted); }
/* SANCTIONED EXCEPTION to the no-animations house rule (explicitly requested):
   ticking the checkbox makes the detective emoji fade in and out for one
   second. Scoped to this one control - do not add animations elsewhere. */
.interest-ctl .i-emoji { opacity: 0; }
.interest-ctl .i-emoji.flash { animation: interest-fade 1s ease; }
@keyframes interest-fade {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---- Feed density (the "Feed density" web setting) ------------------------ */
.feed.compact .post { padding: .55rem .7rem; margin-bottom: .6rem; }
.feed.compact .post h3 { font-size: 1.05rem; }

/* ============================================================================
   ARTICLE / POST CONTENT - the "web-like" rendering of a research article.
   Shared by the compose preview (new_post.html) and the read view (post.html).
   article_content is a list of typed blocks (header / subheader / text / link /
   image / video / embed); these style the rendered DOM. Stays on-style: serif,
   square, flat, no shadow. The renderer is Website/post_render.js.
   ========================================================================== */
.article { line-height: 1.5; }
.article > * { margin: 0 0 1rem; }
.article .post-h   { font-size: 1.5rem; font-weight: bold; margin-top: 1.5rem; }
.article .post-sub { font-size: 1.2rem; font-weight: bold; margin-top: 1rem; color: var(--muted); }
.article figure { margin: 1rem 0; }
.article .post-img { display: block; max-width: 100%; height: auto; border: 1px solid var(--rule-soft); }
.article figcaption { font-size: .85rem; color: var(--muted); margin-top: .3rem; }
.article video { display: block; max-width: 100%; border: 1px solid var(--rule-soft); }
/* Embeds (X/Twitter, YouTube, third-party sites) sit in a bordered frame. */
.article .embed { border: 1px solid var(--rule-soft); }
.article .embed iframe { display: block; width: 100%; border: 0; }
.article .embed.video-embed iframe { aspect-ratio: 16 / 9; height: auto; }
.article .embed.site-embed iframe { height: 30rem; }
.article .embed-fallback { padding: .6rem .8rem; font-size: .9rem; }

/* Post-in-post embedding: a link to another Ocufolio post renders as a small
   preview card of the embedded article, at the link's own position. */
.article .post-embed { border: 1px solid var(--ink); padding: .8rem 1rem; color: var(--muted); }
.article .post-embed-link { display: block; color: inherit; text-decoration: none; }
.article .post-embed-link:hover .post-embed-title { color: var(--feed-hover); }
.post-embed-kind {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: .3rem;
}
.post-embed-title { font-size: 1.05rem; font-weight: bold; color: var(--ink); margin-bottom: .2rem; }
.post-embed-byline { font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
.post-embed-summary { font-size: .9rem; color: var(--ink); }

/* "X Embed/s" count on a post (post.html) - omitted entirely when 0. Clicking
   toggles the list of posts that embedded this one (fetched on demand). */
.embed-count-row { margin-top: .5rem; }
.embed-count-btn {
  font-family: "Times New Roman", Times, serif; font-size: .85rem;
  background: none; border: none; padding: 0; color: var(--green-dark);
  text-decoration: underline; cursor: pointer; width: auto;
}
.embedded-by-list { margin-top: .6rem; border-top: 1px solid var(--rule); padding-top: .6rem; }

/* The post header block (title, byline, TL;DR, prediction) on the read view. */
.post-head { border-bottom: 2px solid var(--rule); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.post-head .byline { color: var(--muted); font-size: .95rem; margin: .3rem 0 .8rem; }
.post-head .tldr {
  border-left: 3px solid var(--rule-soft); padding: .2rem 0 .2rem .8rem;
  margin: .8rem 0; color: var(--muted); font-style: italic;
}
.post-head .prediction { font-weight: bold; }

/* The block editor on the compose page (new_post.html). */
.block { border: 1px solid var(--rule-soft); padding: .7rem .8rem; margin-bottom: .8rem; }
.block .block-head {
  display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem;
  font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.block .block-head .spacer { margin-left: auto; }
.block .block-head button {
  width: auto; border: 1px solid var(--rule-soft); background: #fff; color: var(--ink);
  font-family: "Times New Roman", Times, serif; cursor: pointer; padding: .1rem .5rem; font-size: .9rem;
}
.block textarea { min-height: 4rem; }
.add-blocks { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; }
.add-blocks button {
  width: auto; border: 1px solid var(--ink); background: #fff; color: var(--ink);
  font-family: "Times New Roman", Times, serif; cursor: pointer; padding: .35rem .7rem; font-size: .95rem;
}
.add-blocks button:hover { background: #eef7f0; }

/* ---- Rich-text (WYSIWYG) editor: shared by new_post.html & editor.html ---- */
.rt-toolbar { margin-bottom: .5rem; }
.rt-toolbar button { font-weight: bold; min-width: 2.2rem; }
.rt-editor {
  border: 1px solid var(--ink); padding: .8rem; min-height: 16rem; line-height: 1.5;
  outline: none; background: transparent;
}
.rt-editor:focus { border-color: var(--green-dark); }
.rt-editor:empty:before { content: attr(data-placeholder); color: var(--muted); }
.rt-editor img { max-width: 100%; height: auto; }

/* ---- Tabs (profile: Research Articles / Recent Trades) --------------------
   Classic "folder tab" look: the active tab shares the page/box background and
   merges into the panel below it; inactive tabs are muted. The active colour
   therefore tracks the theme (white / sepia paper / black) rather than the brand
   green. */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--rule); margin: 1rem 0 1.25rem; }
.tabs button {
  width: auto; font-family: "Times New Roman", Times, serif; font-size: 1.05rem; font-weight: bold;
  background: transparent; color: var(--muted); border: 1px solid transparent; border-bottom: none;
  padding: .5rem 1.1rem; cursor: pointer; margin-right: .3rem; margin-bottom: -2px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active {
  background: var(--bg); color: var(--ink);
  border-color: var(--rule); border-bottom: 2px solid var(--bg);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Profile biography ---------------------------------------------------- */
.bio { margin: .25rem 0 1.25rem; white-space: pre-wrap; word-wrap: break-word; }
.bio.empty-bio { color: var(--muted); font-style: italic; border: 1px dashed var(--rule-soft);
                 padding: .6rem .8rem; text-align: left; }

/* A "Draft" badge on the author's unpublished posts. */
.draft-badge {
  display: inline-block; font-size: .7rem; font-weight: bold; text-transform: uppercase;
  letter-spacing: .04em; border: 1px solid var(--rule-soft); color: var(--muted);
  padding: .05rem .4rem; margin-left: .4rem; vertical-align: middle;
}

/* ---- "Leaving Ocufolio" confirm modal (external_links.js) ----------------- */
.extlink-modal {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .5);
}
.extlink-modal .box {
  background: #fff; color: var(--ink); border: 2px solid var(--rule);
  max-width: 30rem; width: calc(100% - 2rem); padding: 1.25rem 1.5rem;
}
.extlink-modal h2 { margin-top: 0; }
.extlink-modal .target {
  word-break: break-all; font-family: monospace; font-size: .9rem;
  border: 1px solid var(--rule-soft); padding: .4rem .6rem; margin: .6rem 0 1rem;
}
.extlink-modal .row { display: flex; gap: .8rem; justify-content: flex-end; }

/* ---- Shared site footer (legal links) ------------------------------------- */
.site-footer {
  border-top: 1px solid var(--rule); margin-top: 3rem; padding-top: 1rem;
  color: var(--muted); font-size: .9rem; text-align: center;
}
.site-footer a { margin: 0 .6rem; }
.site-footer .copyright { margin-top: .5rem; }

/* ---- Searchable ticker combobox (ticker_combo.js) ------------------------- *
   A text input you type into to filter the ~30k-symbol catalogue (queried from the
   server as you type), with a dropdown of "TICKER - Full name" matches. Used by the
   add-trade picker and the article-prediction rows. Square, flat, no shadow. */
.combo { position: relative; }
.combo > input[type="text"] { width: 100%; box-sizing: border-box; }
.combo-list {
  list-style: none; margin: 0; padding: 0; position: absolute; left: 0; right: 0; z-index: 30;
  background: var(--bg); color: var(--ink); border: 2px solid var(--ink); border-top: none;
  max-height: 16rem; overflow-y: auto;
}
.combo-list li { padding: .35rem .5rem; cursor: pointer; border-bottom: 1px solid var(--rule-soft); }
.combo-list li:last-child { border-bottom: none; }
.combo-list li.active, .combo-list li:hover { background: var(--rule-soft); }
.combo-list li .tk { font-weight: bold; }
.combo-list li .desc { color: var(--muted); }
.combo-list li.note { color: var(--muted); cursor: default; font-style: italic; }
.combo-list li.note:hover { background: var(--bg); }

/* ---- Follows (followers / following) list modal --------------------------- *
   Revealed by clicking the follower/following counts on a profile. Mirrors the
   external-link modal but theme-aware (var(--bg)/var(--ink)). */
.follows-modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .5);
}
.follows-modal .box {
  background: var(--bg); color: var(--ink); border: 2px solid var(--rule);
  max-width: 26rem; width: calc(100% - 2rem); max-height: 80vh; display: flex; flex-direction: column;
}
.follows-modal .box-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem 1rem; border-bottom: 1px solid var(--rule); font-weight: bold;
}
.follows-modal .box-head button {
  border: none; background: none; cursor: pointer; font-size: 1.2rem; width: auto; color: var(--ink); padding: 0 .3rem;
}
.follows-modal ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.follows-modal li { padding: .55rem 1rem; border-bottom: 1px solid var(--rule-soft); }
.follows-modal li:last-child { border-bottom: none; }
.follows-modal li a { font-weight: bold; }
.follows-modal li .handle { color: var(--muted); font-weight: normal; }
.follows-modal .empty { padding: 1rem; }
.counts a { cursor: pointer; }
