/* ==========================================================================
   Tyfu — layout: page frame, header, navigation, grids.
   Phones (< 768px): compact top bar + fixed bottom tab bar.
   Tablets and up (≥ 768px): one-row header with the main links.
   ========================================================================== */

.wrap { width: min(1120px, 100% - 1.75rem); margin-inline: auto; }

main { flex: 1 0 auto; padding: 1.25rem 0 2.5rem; }

/* A test copy of the site says so, unmissably. */
.site-banner {
  background: repeating-linear-gradient(135deg, #8a4226 0 14px, #9a4b2b 14px 28px);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  padding: 0.4rem 1rem;
}

/* --------------------------------------------------------------- Header -- */

.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--header-h);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--leaf-dark);
  margin-right: auto;
  min-height: var(--tap);
}
.wordmark-icon { width: 30px; height: 30px; flex: none; }
.wordmark strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.wordmark small {
  display: none;
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Main links: hidden on phones (the tab bar takes over). */
.main-nav { display: none; }

.header-actions { display: flex; align-items: center; gap: 0.4rem; }

/* ----------------------------------------------------------------- Bell -- */

.bell-wrap { position: relative; }

.bell {
  position: relative;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--leaf-dark);
  text-decoration: none;
}
.bell:hover { background: var(--leaf-wash); color: var(--leaf-dark); }
.bell svg { width: 22px; height: 22px; }

.bell-badge {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 19px;
  text-align: center;
}
.bell-badge.is-hidden { display: none; }

.bell-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  width: min(22rem, calc(100vw - 2rem));
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  z-index: 60;
  overflow: hidden;
}
.bell-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.bell-panel-foot { padding: 0.6rem 0.9rem; border-top: 1px solid var(--line); font-size: 0.875rem; }

/* ------------------------------------------------------- Account menu -- */

.account-menu { position: relative; }
.account-menu > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0 0.25rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
}
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary:hover { background: var(--leaf-wash); }
.account-menu[open] > summary { background: var(--leaf-wash); }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--leaf);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: none;
}
.avatar.is-pupil { background: var(--water); }
.account-name { display: none; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }

.account-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  width: min(18rem, calc(100vw - 1.5rem));
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  z-index: 60;
  padding: 0.5rem;
}
.account-panel-who { padding: 0.5rem 0.6rem 0.7rem; border-bottom: 1px solid var(--line); margin-bottom: 0.35rem; }
.account-panel-who strong { display: block; }
.account-panel-who span { display: block; font-size: 0.82rem; color: var(--muted); overflow-wrap: anywhere; }
.account-panel a,
.account-panel button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--tap);
  padding: 0 0.6rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.account-panel a:hover,
.account-panel button:hover { background: var(--leaf-wash); color: var(--leaf-dark); }

/* ------------------------------------------------------ Phone tab bar -- */

.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  background: var(--paper);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(44, 52, 44, 0.06);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-bar a {
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
}
.tab-bar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.tab-bar svg { width: 24px; height: 24px; padding: 3px 12px; box-sizing: content-box; border-radius: 999px; }
.tab-bar a.is-active { color: var(--leaf-dark); font-weight: 600; }
.tab-bar a.is-active svg { background: var(--leaf-wash); }

html.has-tabbar body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
/* Anything scrolled into view (keyboard focus, in-page links) stops clear of
   the tab bar instead of underneath it. */
html.has-tabbar { scroll-padding-bottom: calc(var(--tabbar-h) + 1rem); }
/* The on-screen keyboard pushes a fixed bar up over the form; hide it while typing. */
body.keyboard-open .tab-bar { display: none; }

/* --------------------------------------------------------- Page blocks -- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-head p { color: var(--muted); margin: 0.15rem 0 0; }

.back-link { display: inline-flex; align-items: center; min-height: var(--tap); font-size: 0.9rem; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.1rem 0;
  font-size: 0.82rem;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.6);
}
.site-footer p { margin: 0; }

/* -------------------------------------------------------------- Grids -- */

.grid { display: grid; gap: var(--gap); }
/* min(100%, …) means a grid can never be wider than a small phone. */
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
/* At most three columns, however wide the screen. */
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, max(15rem, (100% - 2 * var(--gap)) / 3)), 1fr)); }
.dashboard-grid { grid-template-columns: minmax(0, 1fr); align-items: start; }
.dashboard-grid > div { display: grid; gap: var(--gap); align-content: start; }

.card-narrow { max-width: 40rem; }

/* ------------------------------------------------------------ Tablets -- */

@media (min-width: 768px) {
  html.has-tabbar { scroll-padding-bottom: 0; }
  .wrap { width: min(1120px, 100% - 3rem); }
  main { padding: 2rem 0 3.5rem; }

  .tab-bar { display: none; }
  html.has-tabbar body { padding-bottom: 0; }

  .header-inner { gap: 1rem; min-height: 64px; }
  .main-nav { display: flex; gap: 0.15rem; }
  .main-nav a {
    display: flex;
    align-items: center;
    min-height: var(--tap);
    padding: 0 0.7rem;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
  }
  .main-nav a:hover { background: var(--leaf-wash); color: var(--leaf-dark); }
  .main-nav a.is-active { background: var(--leaf); color: #fff; }

  .page-head { margin-bottom: 1.5rem; }
}

/* ------------------------------------------------------------ Desktop -- */

@media (min-width: 1024px) {
  .header-inner { gap: 1.25rem; }
  .wordmark small { display: block; }
  .main-nav a { padding: 0 0.85rem; }
  .account-name { display: block; }
  .dashboard-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
}
