/* =========================================================
   YOOHPEY EDU SITE — CORE THEME + COMPONENTS
   - Default: LIGHT
   - Dark only when forced with ?theme=dark
   - Reusable across all pages (home, diagram, dialogue, etc.)
   ========================================================= */

/* -------------------------
   TOKENS
------------------------- */

:root{
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.14);
  --shadow2: 0 14px 40px rgba(0,0,0,.20);
  --pad: 16px;
  --gap: 16px;
  --max: 1050px;

  /* LIGHT DEFAULT (blue-ish pleasant paper) */
  --bg: #f6f7fb;
  --bg2: #ffffff;
  --text: #151826;
  --muted: #5c647a;
  --border: rgba(15,17,26,.10);
  --hover-border: rgba(15,17,26,.18);

  --thumb-bg: rgba(15,17,26,.04);
  --tag-bg: rgba(15,17,26,.05);
  --tag-border: rgba(15,17,26,.10);
}

/* Forced dark theme */
html[data-theme="dark"]{
  --bg: #0f111a;
  --bg2: #151827;
  --text: #e7eaf3;
  --muted: #aab1c6;
  --border: rgba(255,255,255,.08);
  --hover-border: rgba(255,255,255,.16);

  --thumb-bg: rgba(255,255,255,.03);
  --tag-bg: rgba(255,255,255,.06);
  --tag-border: rgba(255,255,255,.08);

  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --shadow2: 0 14px 40px rgba(0,0,0,.45);
}

/* -------------------------
   BASE PAGE LAYOUT
------------------------- */

*{ box-sizing: border-box; }

body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.yhp-wrap{
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 18px 42px;
}

.yhp-header{
  margin-bottom: 18px;
}

.yhp-title{
  font-size: 1.4rem;
  margin: 0 0 6px 0;
  font-weight: 700;
  letter-spacing: .2px;
}

.yhp-lede{
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

/* Useful for generic pages */
.yhp-page{
  margin-top: 18px;
}

/* -------------------------
   GRID + CARD COMPONENT
------------------------- */

.yhp-grid{
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--gap);
}

.yhp-card{
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.yhp-card:hover,
.yhp-card:focus-visible{
  transform: translateY(-2px);
  box-shadow: var(--shadow2);
  border-color: var(--hover-border);
  outline: none;
}

.yhp-thumb{
  aspect-ratio: 16 / 9;
  height: auto;
  background: var(--thumb-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.yhp-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.yhp-card-content{
  padding: var(--pad);
}

.yhp-card-title{
  margin: 0 0 6px 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.yhp-card-desc{
  margin: 0;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.35;
}

.yhp-tag{
  display:inline-block;
  margin-top: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  color: var(--muted);
  font-size: .8rem;
}

/* -------------------------
   OPTIONAL: A “panel” container for non-card pages
   (nice for dialogue page or explanatory text)
------------------------- */

.yhp-panel{
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* Floating back button (bottom-left) */
.yhp-back{
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 99999;

  display: inline-flex;
  align-items: center;
  gap: 10px;

  padding: 10px 12px;
  border-radius: 999px;

  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);

  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  user-select: none;

  opacity: 0.75;
  transition: opacity .12s ease, transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  backdrop-filter: blur(6px);
}

.yhp-back:hover,
.yhp-back:focus-visible{
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: var(--shadow2);
  border-color: var(--hover-border);
  outline: none;
}

.yhp-back::before{
  content: "←";
  display: inline-block;
  transform: translateY(-1px);
}

/* Optional: on very small screens, keep it tucked */
@media (max-width: 420px){
  .yhp-back{
    left: 10px;
    bottom: 10px;
    padding: 9px 11px;
  }
}

/* =========================
   Sticky footer bar
   ========================= */

:root{
  --footer-h: 46px;
  --footer-pad-x: 12px;
}

/* Reserve space so content never hides behind footer */
body{ padding-bottom: var(--footer-h); }

.yhp-footer{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999;

  /* Avoid text clipping: use min-height not hard height */
  min-height: var(--footer-h);

  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 10px;

  padding: 6px var(--footer-pad-x);

  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 30px rgba(0,0,0,.10);
  backdrop-filter: blur(6px);
}

/* Side cells */
.yhp-footer-side{
  min-width: 0;
  display: flex;
  align-items: center;
}

/* Home aligned left within its side cell */
.yhp-footer-left{ justify-content: flex-start; }

/* Right side is empty, but exists to balance the left side */
.yhp-footer-right{ justify-content: flex-end; }

/* Centre text */
.yhp-footer-center{
  min-width: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.2;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Home button */
.yhp-footer-home{
  display: inline-flex;
  align-items: center;
  gap: 8px;

  padding: 8px 10px;
  border-radius: 999px;

  background: transparent;
  border: 1px solid transparent;

  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  user-select: none;

  opacity: 0.9;
  transition: opacity .12s ease, transform .12s ease, border-color .12s ease, background .12s ease;
}

.yhp-footer-home::before{ content: "←"; transform: translateY(-1px); }

.yhp-footer-home:hover,
.yhp-footer-home:focus-visible{
  opacity: 1;
  transform: translateY(-1px);
  border-color: var(--hover-border);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  outline: none;
}

@media (max-width: 480px){
  /* Give the text more room by collapsing the right balance cell */
  .yhp-footer{
    grid-template-columns: auto 1fr 0px;
    column-gap: 8px;
    padding: 6px 10px;
  }

  .yhp-footer-right{
    display: none;
  }

  .yhp-footer-center{
    font-size: 0.85rem;
  }
}