/* Jhome Hosting -- app shell stylesheet.
   Calm, legible dashboard chrome for a technical-but-not-expert customer
   managing one or two sites. Function over expression: nothing here should
   draw attention to itself.

   Accent is THIS app's own green (#2f6f4f) -- not Trading Jay's purple. The
   bottom-tab mobile nav copies Trading Jay's structure/sizing verbatim
   (bar height, tab layout, the neutral slate inactive colour, borders) and
   recolors only the accent. See design-system.css in trading-jay/dashboard
   for the reference this was built from.

   Contrast pairs were computed against the WCAG relative-luminance formula,
   not eyeballed -- see this task's HANDOFF/report for the actual numbers.
*/

:root {
  color-scheme: dark;
  --bg: #0a0c14;
  --surface: #141720;
  --border: #1e2535;
  --text: #e8ecf4;
  --muted: #a0aec0;
  --slate: #718096;
  --accent: #2f6f4f;
  --accent-light: #4a9d72;
  --accent-dark: #255a3f;
  --danger: #f6a5a5;
  --danger-bg: rgba(200, 60, 60, 0.16);
  --danger-border: rgba(200, 60, 60, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

/* The shell is the ONLY place min-height:100vh is allowed. .content uses
   flex:1 to fill the remaining space, which is what keeps the brand footer
   visible on a short page instead of a 100vh page pushing it off screen. */
.shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

/* --- Typography ------------------------------------------------------- */
/* Prose floor: 16px minimum, 17px is the actual default. Line-height
   1.5-1.7. Labels/badges/eyebrows below are the only exemptions. */

h1 { font-size: 1.7rem; line-height: 1.3; margin: 0 0 1rem; }
h2 { font-size: 1.3rem; line-height: 1.35; margin: 2rem 0 0.75rem; }

p, li, td, label { font-size: 17px; line-height: 1.6; }

/* accent-light (not the raw accent) so link text clears 4.5:1 against the
   dark background -- see this task's report for the measured numbers. The
   hover state adds an underline rather than darkening the color, since
   darkening to --accent would drop that pair below the floor. */
a { color: var(--accent-light); }
a:hover { text-decoration: underline; }

.hint { font-size: 16px; line-height: 1.55; color: var(--muted); margin: 0.4rem 0 0; }

.error {
  font-size: 17px;
  line-height: 1.55;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}

/* --- Install affordance -------------------------------------------------
   Quiet by design: it sits directly above the brand credit on every page,
   so it must read as a small offer, not a banner. Hidden until the browser
   confirms the app is installable. */

.install-bar { text-align: center; padding: 0 1rem; }

.install-btn {
  margin-top: 0;
  padding: 0.45rem 1.1rem;
  font-size: 16px;
  color: var(--accent-light);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 160ms ease, color 160ms ease;
}
/* Beats `button:hover`'s filled accent: this is a ghost button, and the
   filled treatment is reserved for a page's primary action. */
.install-btn:hover { background: transparent; border-color: var(--accent-light); }
.install-btn:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }
.install-btn:disabled { opacity: 0.6; cursor: default; }
/* The `button` rule above sets no display, so [hidden] would work on its own.
   Stated anyway: a future display rule on .install-btn would silently unhide
   the button on every page for everyone. */
.install-btn[hidden] { display: none; }

/* Fine print: footer credit, table meta -- 14px floor, never smaller. */
.brand-credit {
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
}
.brand-credit a { color: var(--muted); text-decoration: underline; }
.brand-credit a:hover { color: var(--text); }

/* --- Signed-out landing (GET /) ----------------------------------------
   The one page rendered without either nav, so it also drops the
   bottom-tab clearance the rest of the app needs below 1024px. */

/* Centred in whatever space the shell leaves. .content is already flex:1
   inside the shell's flex column, so this just uses the room it was given;
   if the content ever outgrows the viewport the flex item grows instead and
   justify-content becomes a no-op, so nothing can be clipped. */
.landing {
  max-width: 34rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Lead paragraph: 20px floor, per the house type rules. */
.landing .lead {
  font-size: 20px;
  line-height: 1.55;
  margin: 0 0 1.75rem;
}

.landing .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.25rem 1.4rem;
}
.landing .panel h2 { margin-top: 0; }

/* Same accent pair and hover as `button` -- white on --accent measures
   6.0:1 -- because this is a button that happens to be a link. */
.cta {
  display: inline-block;
  margin-top: 1.1rem;
  padding: 0.7rem 1.4rem;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
  text-decoration: none;
  transition: background 160ms ease;
}
.cta:hover { background: var(--accent-dark); text-decoration: none; }
.cta:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }

/* --- Forms -------------------------------------------------------------- */

label { font-weight: 600; margin-top: 1.25rem; }

input, textarea, select {
  font-size: 17px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  padding: 0.6rem 0.75rem;
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
}

/* Placeholders must clear 4.5:1 against the input background just like
   body text -- --muted on --surface measures 7.94:1. */
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }

button {
  font-size: 17px;
  font-family: inherit;
  font-weight: 600;
  width: auto;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 0.7rem 1.4rem;
  margin-top: 1.5rem;
}
button:hover { background: var(--accent-dark); }

/* --- Tables --------------------------------------------------------------*/

/* House rule: wide content scrolls inside its OWN container -- the page
   body never scrolls sideways. Without this, a site's live address (one
   long unbreakable token) set the table's minimum width and dragged the
   whole document with it: 437px of scrollWidth on a 375px screen. */
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 16px; }
th, td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--border); }

/* The container above stops the PAGE scrolling; this stops the table
   needing to scroll at all in the common case. `anywhere` rather than
   `break-word` is the load-bearing part: only `anywhere` reduces the
   min-content width, which is what lets the address column collapse. */
td { overflow-wrap: anywhere; }

.status-pill {
  display: inline-block;
  font-size: 13px; /* uppercase micro-copy label, exempt from the prose floor */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  /* `td { overflow-wrap: anywhere }` (added for long addresses) otherwise
     breaks this badge mid-word -- "LIVE" wrapped to "LIV / E" and the pill
     rendered as a circle. A short status label never wraps. */
  white-space: nowrap;
}

/* --- Deploy cards + the mobile card deck --------------------------------
   The deploys list is cards, not a table: three columns put a version, a
   badge and a timestamp into 375px and wrapped the timestamp over four
   lines. Above 1024px the cards simply stack; below it, static/js/deck.js
   turns the container into a one-card-at-a-time deck.

   Structure, sizing and control language are ported from the house
   reference (jhome-Platform/funnel, MOBILE CARD DECK), recoloured to this
   app's own green -- the accent always matches the host site. */

.deck { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }

.deploy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.deploy-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.deploy-card h3 { margin: 0; font-size: 17px; line-height: 1.35; }
.deploy-card .hint { margin-top: 0.35rem; }
.deploy-card p:last-child { margin-bottom: 0; }

@media (max-width: 1024px) {
  [data-deck] {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 1rem !important;
    padding-bottom: 0.5rem;
    /* DEVIATION from the house reference, which sets align-items:flex-start
       so a short card is not padded out to the tallest in the set. That is
       right for its 1500px story cards. These are small status cards --
       92px next to 191px -- and flex-start left a ~107px void of page
       background under the short ones, which reads as a broken layout. The
       track is as tall as its tallest child either way; stretching fills
       that space with card instead of hole. Measured, not assumed. */
    align-items: stretch;
  }
  [data-deck]::-webkit-scrollbar { display: none; }

  [data-deck] > * {
    flex: 0 0 100%;
    min-width: 0;
    scroll-snap-align: center;
    scroll-snap-stop: always;
  }

  .deck-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.1rem;
  }
  /* A bar above the track as well as below it: a card can be taller than
     the screen, and a reader seeing only its top gets no signal that there
     are others. */
  .deck-controls-top { margin-top: 1rem; margin-bottom: 0.9rem; }

  .deck-nav {
    width: 46px;   /* 44px minimum touch target, as on the reference */
    height: 46px;
    flex-shrink: 0;
    margin-top: 0;
    padding: 0;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 160ms ease, color 160ms ease;
  }
  .deck-nav svg { width: 1.1rem; height: 1.1rem; display: block; }
  .deck-nav:not(:disabled):hover { background: var(--surface); border-color: var(--accent-light); }
  .deck-nav:disabled { opacity: 0.35; cursor: default; }
  .deck-nav:not(:disabled):active { transform: scale(0.95); }
  .deck-nav:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }

  .deck-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    flex-wrap: wrap;
  }
  .deck-dot {
    width: 11px;
    height: 11px;
    margin-top: 0;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    transition: width 300ms cubic-bezier(0.22, 0.61, 0.36, 1),
                background-color 300ms ease, border-color 300ms ease;
  }
  .deck-dot[aria-current="true"] {
    width: 36px;
    border-radius: 6px;
    border-color: transparent;
    background: var(--accent-light);
  }
  .deck-dot:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 3px; }
}

/* Scoped to the desktop side rather than left unscoped: an unscoped
   `display: none` sits after the media query and wins at equal specificity,
   which hides the controls on mobile too. */
@media (min-width: 1025px) {
  .deck-controls { display: none; }
}

/* --- Desktop top nav ---------------------------------------------------- */

.desktop-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.desktop-nav .brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 17px; }
.desktop-nav .links { display: flex; gap: 1.5rem; }
.desktop-nav a { font-size: 16px; text-decoration: none; color: var(--muted); }
.desktop-nav a:hover, .desktop-nav a.active { color: var(--accent-light); }

/* --- Mobile bottom-tab nav ----------------------------------------------
   House rule: activates at iPad-retina size and below (1024px), not just
   phone size -- tablet users get the chunkier bottom-tab UX too. Chrome
   (bar height, tab layout, sizes, the neutral slate inactive colour, dark
   ground, borders) is copied from Trading Jay verbatim; only the accent is
   recoloured to this app's own green. */

#hosting-mobile-nav { display: none; }

@media (max-width: 1024px) {
  .desktop-nav { display: none; }

  /* Nav clearance lives on .shell below, not here: padding on .content
     clears the nav for the page's own content but does nothing for the
     brand credit and install button, which come AFTER it. */

  #hosting-mobile-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: calc(60px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: #0a0c14;
    border-top: 1px solid var(--border);
    z-index: 20;
  }

  .tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--slate);
    text-decoration: none;
    transition: color 120ms ease;
  }
  .tab-icon { font-size: 1.15rem; line-height: 1; }
  .tab-icon svg { width: 1.15em; height: 1.15em; display: block; }
  .tab-label {
    font-size: 0.58rem; /* uppercase micro-copy, exempt from the prose floor */
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
  }
  .tab:hover { color: var(--accent-light); }
  /* Active tab uses accent-light, not the raw --accent, so the label still
     clears 4.5:1 against the near-black nav background (see report for the
     measured numbers) -- the raw accent alone falls short at this size. */
  .tab.active { color: var(--accent-light); }

  /* A page's own footer sits above the fixed nav bar rather than under it.
     This said exactly that and set 0, which is what it was there to prevent:
     .shell is min-height:100vh, so its last element -- the brand credit, and
     the install button above it -- landed in the exact 60px the fixed nav
     covers, on an unscrollable page. Both were invisible on every app page
     below 1024px. Measured, not guessed: credit 751-812, nav top 752.

     Scoped with :has() because the landing page renders no bottom-tab nav
     and must not get a 60px void above its credit instead. */
  .shell:has(~ #hosting-mobile-nav) {
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
  }
}

/* Motion ships in the same change as the transition that needs it. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
