/* EmmaFocusFix Portal — shared styles
   Brand system: Off-white / Dark Olive / Olive / Charcoal / Gold / Terracotta / Beige / Taupe
   Fonts: Playfair Display (editorial) · DM Sans (functional) · Fredoka (children's content only) */

:root {
  --off-white: #F7F3EF;
  --olive: #8CA02F;
  --olive-light: #A3B84A;
  --dark-olive: #3E4A24;
  --dark-olive-hover: #4C5A2C;
  --charcoal: #3B3B3B;
  --gold: #C9A961;
  --gold-text: #412402;
  --terracotta: #C15C34;
  --terracotta-dark: #993C1D;
  --beige: #E9E2D6;
  --taupe: #B8A18E;
  --warm-white: #FFFFFF;
  --text-secondary: #7A756C;
  --radius-card: 18px;
  --radius-control: 8px;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--off-white);
  color: var(--charcoal);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3, .voice {
  font-family: 'Playfair Display', serif;
  font-weight: 500;
  color: var(--charcoal);
  margin: 0;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar / top bar ----------
   Landscape (laptop, tablet or phone turned sideways): vertical bar on the left.
   Portrait (phone or tablet held upright): horizontal bar across the top, with
   a Menu button that opens the full list. Switching is pure CSS, so rotating
   the device changes the layout instantly with no reflow delay. */

.sidebar {
  background: var(--dark-olive);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: var(--sidebar-width);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav-brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.sidebar .logo {
  width: 100%;
  max-width: 200px;
  height: auto;
  margin: 0 0 28px 6px;
  display: block;
}

.nav-toggle {
  display: none;
  align-items: center;
  gap: 7px;
  background: rgba(247, 243, 239, 0.10);
  color: var(--warm-white);
  border: 0.5px solid rgba(247, 243, 239, 0.22);
  border-radius: var(--radius-control);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
  min-height: 40px;
}
.nav-toggle i { font-size: 17px; }

.nav-scroll { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.nav-list { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  color: var(--beige);
  font-size: 14px;
  transition: background 0.15s ease;
}
.nav-item i { font-size: 18px; }
.nav-item:hover { background: var(--dark-olive-hover); color: var(--warm-white); }
.nav-item.active { background: var(--olive); color: var(--warm-white); font-weight: 500; }

.nav-secondary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 0.5px solid rgba(247, 243, 239, 0.15);
}
.nav-secondary .nav-item { color: var(--taupe); font-size: 13px; padding: 9px 12px; }
.nav-secondary .nav-item i { font-size: 16px; }
.nav-secondary .nav-item:hover { color: var(--warm-white); }

/* ---------- Main content ---------- */
.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1440px;
}

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 600; }
.page-header p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--taupe);
  margin-bottom: 8px;
  display: block;
}
.eyebrow.accent { color: var(--olive); }

/* ---------- Cards ---------- */
.card {
  background: var(--warm-white);
  border: 0.5px solid var(--beige);
  border-radius: var(--radius-card);
  padding: 20px 22px;
}

.card-row { display: flex; flex-direction: column; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: var(--radius-control);
  padding: 10px 18px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--terracotta); color: var(--warm-white); }
.btn-action { background: var(--olive); color: var(--warm-white); }
.btn-outline { background: var(--warm-white); color: var(--dark-olive); border: 0.5px solid var(--olive); }
.btn-ghost { background: var(--warm-white); color: var(--charcoal); border: 0.5px solid var(--taupe); }
.btn-danger { background: var(--warm-white); color: var(--terracotta-dark); border: 0.5px solid #F0997B; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
}
.badge-locked { background: var(--beige); color: var(--dark-olive); }
.badge-unlocked { background: #E1ECC8; color: var(--dark-olive); }

/* ---------- List rows (Modules / Guides) ---------- */
.list-row {
  background: var(--warm-white);
  border: 0.5px solid var(--beige);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.list-row.in-progress { border-color: var(--terracotta); }
.row-badge {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--warm-white); font-size: 12px; font-weight: 500; flex-shrink: 0;
}
.row-title { font-size: 14px; font-weight: 500; }
.row-sub { font-size: 12px; color: var(--text-secondary); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; color: var(--charcoal); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 0.5px solid var(--beige);
  border-radius: var(--radius-control);
  background: var(--warm-white);
  color: var(--charcoal);
  margin-bottom: 16px;
}
textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: -10px; margin-bottom: 16px; }

/* ---------- Responsive ----------
   The switch is driven by orientation, so turning the device sideways moves
   the bar from the top to the left immediately. A width fallback covers the
   rare landscape phone that is still too narrow for a side bar. */

/* ===== Home Progress Snapshot: tablet/desktop only, both orientations =====
   This is independent of the sidebar/orientation system above — it's a
   device-class check (phone vs tablet), not a layout check. A phone and a
   tablet can share the same orientation, so the sidebar rules above can't
   tell them apart on their own. The distinguishing signal is the device's
   short edge: on a phone that's under ~480px whichever way it's held; on an
   iPad it's 768px+ even in landscape. min-width covers portrait and desktop;
   the second query specifically catches landscape phones, which can be wide
   (700–930px) but are always short — real tablets in landscape stay tall. */
.home-progress-snapshot { display: none; }

@media (min-width: 768px) {
  .home-progress-snapshot { display: block; }
}

@media (max-height: 600px) and (pointer: coarse) {
  .home-progress-snapshot { display: none; }
}

/* ===== PORTRAIT: bar across the top ===== */
@media (orientation: portrait), (max-width: 720px) {
  .app-shell { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 60;
    box-shadow: 0 2px 12px -6px rgba(43, 42, 38, 0.5);
  }

  .nav-brand { margin: 0; }

  .sidebar .logo {
    width: auto;
    max-width: 168px;
    margin: 0;
    flex-shrink: 1;
    min-width: 0;
  }

  .nav-toggle { display: inline-flex; }

  /* Collapsed by default; the Menu button opens it. */
  .nav-scroll {
    flex: none;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.22s ease, opacity 0.18s ease, margin-top 0.22s ease;
    margin-top: 0;
  }
  .sidebar.is-open .nav-scroll {
    max-height: 640px;
    opacity: 1;
    margin-top: 12px;
    overflow-y: auto;
  }

  .nav-list { flex: none; }

  .nav-item { min-height: 46px; font-size: 14.5px; }

  .nav-secondary { padding-top: 10px; margin-top: 10px; }

  .main { padding: 20px; max-width: none; }
}

/* ===== LANDSCAPE on a short screen (phone turned sideways) =====
   Keep the side bar, but slimmer, so the content still gets real width. */
@media (orientation: landscape) and (max-height: 560px) and (min-width: 721px) {
  .sidebar { width: 186px; padding: 14px 12px; overflow-y: auto; }
  .sidebar .logo { max-width: 150px; margin-bottom: 14px; }
  .nav-item { padding: 8px 10px; font-size: 13px; min-height: 0; }
  .nav-item i { font-size: 16px; }
  .nav-secondary { padding-top: 10px; margin-top: 10px; }
  .nav-secondary .nav-item { font-size: 12px; padding: 7px 10px; }
  .main { padding: 18px 22px; }
}

/* ===== Small portrait phones ===== */
@media (orientation: portrait) and (max-width: 767px) {
  .main { padding: 16px; }
  .page-header h1 { font-size: 20px; }
  .sidebar .logo { max-width: 150px; }

  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }

  .card { padding: 16px 18px; }
  .btn { min-height: 44px; }
}

@media (max-width: 420px) {
  .main { padding: 14px; }
  .sidebar { padding: 9px 14px; }
  .sidebar .logo { max-width: 130px; }
  .nav-toggle span { display: none; }
  .nav-toggle { padding: 9px 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
