/* Forge | base.css
   Reset, typography, header, drawer, bottom nav, sidebar, main. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; }
html { font-size: 16px; }

body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background var(--t-normal) var(--ease-in),
              color var(--t-normal) var(--ease-in);
}

h1, h2, h3, h4 {
  color: var(--text-strong);
  font-weight: 700;
  line-height: var(--lh-heading);
  letter-spacing: -0.01em;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
a { color: var(--primary); text-decoration: none; }
img, svg { display: block; max-width: 100%; height: auto; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

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

/* HEADER */
.header {
  position: sticky; top: 0; z-index: 40;
  min-height: var(--header-h);
  display: flex; align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-4);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: background var(--t-normal) var(--ease-in);
}
.header-title {
  flex: 1;
  font-size: var(--fs-h3); font-weight: 600;
  color: var(--text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-actions { display: flex; align-items: center; gap: var(--s-1); }

/* MAIN */
.main {
  flex: 1;
  padding: var(--s-4);
  padding-bottom: calc(var(--nav-h) + var(--s-6));
  animation: page-in var(--t-normal) var(--ease-in);
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* DRAWER (phone) */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5, 6, 12, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-normal) var(--ease-in);
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 95;
  width: min(82vw, 320px);
  background: var(--surface);
  transform: translateX(-100%);
  transition: transform var(--t-drawer) var(--ease-drawer);
  display: flex; flex-direction: column;
  padding: var(--s-5);
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-6);
}
.drawer-brand {
  display: flex; align-items: center; gap: var(--s-3);
  font-weight: 700; font-size: var(--fs-h3); color: var(--text-strong);
}
.drawer-logo {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--gradient-forge);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary-text); font-weight: 700;
}
.drawer-section {
  font-size: var(--fs-tiny); font-weight: 600;
  color: var(--muted-2);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: var(--s-4) 0 var(--s-2);
}
.drawer-nav { display: flex; flex-direction: column; gap: 2px; }
.drawer-nav a {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  color: var(--muted); font-weight: 500;
  transition: background var(--t-fast) var(--ease-in),
              color var(--t-fast) var(--ease-in);
}
.drawer-nav a:hover { background: var(--surface-2); color: var(--text); }
.drawer-nav a[aria-current="page"] {
  background: var(--primary); color: var(--primary-text);
}
.drawer-nav a svg { width: 20px; height: 20px; flex-shrink: 0; }

/* BOTTOM NAV (phone) */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  height: var(--nav-h);
  display: flex; align-items: stretch;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: var(--fs-tiny); font-weight: 500;
  transition: color var(--t-fast) var(--ease-in);
  position: relative;
}
.bottom-nav a[aria-current="page"] { color: var(--primary); }
.bottom-nav a[aria-current="page"]::before {
  content: ''; position: absolute;
  top: 6px; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 999px;
  background: var(--primary);
}
.bottom-nav a svg { width: 22px; height: 22px; }

/* SIDEBAR (desktop) */
.sidebar { display: none; }

@media (min-width: 900px) {
  .app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "sidebar header" "sidebar main";
    min-height: 100vh;
  }
  .header { grid-area: header; }
  .main   { grid-area: main; padding: var(--s-6); padding-bottom: var(--s-6); }
  .sidebar {
    grid-area: sidebar;
    display: flex; flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: var(--s-5);
    gap: 2px;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
  }
  .sidebar-brand {
    display: flex; align-items: center; gap: var(--s-3);
    font-size: var(--fs-h3); font-weight: 700;
    color: var(--text-strong);
    margin-bottom: var(--s-6);
  }
  .sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar-nav a {
    display: flex; align-items: center; gap: var(--s-3);
    padding: var(--s-3);
    border-radius: var(--r-md);
    color: var(--muted); font-weight: 500;
    transition: background var(--t-fast) var(--ease-in),
                color var(--t-fast) var(--ease-in);
  }
  .sidebar-nav a:hover { background: var(--surface-2); color: var(--text); }
  .sidebar-nav a[aria-current="page"] {
    background: var(--primary-soft); color: var(--primary);
  }
  .sidebar-nav a svg { width: 20px; height: 20px; flex-shrink: 0; }
  .sidebar-section {
    font-size: var(--fs-tiny); font-weight: 600;
    color: var(--muted-2);
    text-transform: uppercase; letter-spacing: 0.08em;
    margin: var(--s-4) 0 var(--s-2);
  }
  .bottom-nav { display: none; }
  .header-hamburger { display: none !important; }
  .drawer, .drawer-overlay { display: none !important; }
  .main { max-width: 1100px; margin: 0 auto; width: 100%; }
}

/* Utilities */
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row-wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--s-3); }
.spacer { flex: 1; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.gradient-text {
  background: var(--gradient-forge);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
