/* css/layout.css — base layout and structure */

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body[data-lang="th"] {
  font-family: var(--font-thai);
}

.section {
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
}

/* ── Shared Nav — DRE-7 ───────────────────────────────────────── */

/* Sticky top bar */
.topnav {
  position: sticky; top: 0; z-index: 30;
  height: 56px;
  background: rgba(250,249,247,.92);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}

/* Logo */
.logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  text-decoration: none; color: var(--color-text);
}
.logo .mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--color-primary), #8b5cf6);
  display: grid; place-items: center; color: #fff;
  font-weight: 800; font-size: 13px;
  box-shadow: 0 4px 10px rgba(99,102,241,.35);
  flex-shrink: 0;
}

/* Icon button (hamburger / close) */
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  display: grid; place-items: center;
  cursor: pointer; color: var(--color-text);
  font-size: 18px; line-height: 1;
}
.icon-btn:active { transform: scale(.96); }

/* Topnav right cluster */
.topnav-right { display: flex; align-items: center; gap: 8px; }

/* Desktop nav (hidden by default — mobile-first) */
.nav-desktop { display: none; }

/* Hamburger (visible by default on mobile) */
.nav-hamburger { display: grid; }

/* Drawer scrim */
.drawer-scrim {
  position: fixed; inset: 0; background: rgba(15,12,40,.45); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }

/* Drawer panel */
.drawer {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 85%; max-width: 320px; z-index: 41;
  background: var(--color-bg);
  transform: translateX(-100%);
  transition: transform .26s cubic-bezier(.2,.7,.2,1);
  display: flex; flex-direction: column;
  box-shadow: 6px 0 30px rgba(15,12,40,.18);
}
.drawer.open { transform: translateX(0); }
.drawer > header {
  padding: 16px; display: flex; align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
}
.drawer .nav-list { flex: 1; overflow-y: auto; padding: 8px; }
.drawer > footer { border-top: 1px solid var(--color-border); padding: 16px; }

/* Nav items */
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  min-height: 56px; border-radius: 12px; cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none; color: var(--color-text);
}
.nav-item .num {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: var(--color-muted);
  flex: 0 0 auto;
}
.nav-item.active {
  background: var(--color-primary-50);
  border-color: var(--color-primary-100);
}
.nav-item.active .num {
  background: var(--color-primary); color: #fff;
  border-color: var(--color-primary);
}
.nav-item.active .label { color: var(--color-primary); font-weight: 600; }
.nav-item .check {
  margin-left: auto; color: var(--color-secondary);
  font-size: 18px; line-height: 1;
}
.nav-item .label { font-size: 15px; }

/* Language toggle */
.lang-toggle {
  display: flex; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: 12px;
  padding: 4px; gap: 4px;
}
.lang-toggle button {
  flex: 1; min-height: 40px; border: 0; background: transparent;
  border-radius: 8px; font-weight: 600; font-size: 14px;
  color: var(--color-muted); cursor: pointer;
}
.lang-toggle button.active { background: var(--color-primary); color: #fff; }

/* Desktop override — nav becomes inline at 768px+ */
@media (min-width: 768px) {
  .nav-desktop {
    display: flex; gap: 4px; align-items: center;
    flex: 1; overflow-x: auto; margin: 0 16px;
  }
  .nav-desktop .nav-item {
    min-height: 40px; padding: 6px 10px; font-size: 13px;
    white-space: nowrap;
  }
  .nav-hamburger,
  .drawer,
  .drawer-scrim { display: none !important; }
}

/* ── DRE-8: viewport safety + typography scale ───────────────── */
html, body { overflow-x: hidden; max-width: 100%; }

h1 { font-size: 1.75rem; line-height: 1.25; margin-block: 0.5em 0.4em; font-weight: 700; }
h2 { font-size: 1.4rem;  line-height: 1.3;  margin-block: 1em 0.4em; font-weight: 700; }
h3 { font-size: 1.15rem; line-height: 1.35; margin-block: 0.8em 0.3em; font-weight: 600; }
p  { margin-block: 0.6em; }
body[data-lang="th"] { font-size: calc(16px * 1.05); }

@media (min-width: 640px)  { .section { padding: 24px; max-width: 720px; } }
@media (min-width: 1024px) { .section { max-width: 840px; } }
@media (min-width: 1280px) { .section { max-width: 900px; } }
