/* =========================================================
   Matematikrevyen – Shared Stylesheet
   ========================================================= */

/* --- Palette ---------------------------------------------
   Warm honey/walnut wood theme. Defined here (loaded on every
   page) so all content stylesheets can reference these tokens.
   Øveplan (schedule.css) deliberately references none of them —
   see the body:has(.sched-layout) reset below. */
:root {
  --bg: #e4d3b3;         /* page background (honey oak) */
  --surface: #f1e6cf;    /* cards / cells / panels (warm cream) */
  --surface-2: #eee2cc;  /* secondary fills (rows, hovers) */
  --border: #d3bf9c;     /* borders (tan) */
  --text: #2e2416;       /* primary text (warm near-black) */
  --header: #1f2328;     /* header — unchanged near-black */
  --accent: #3b82d4;     /* blue — solid primary buttons only */
  /* Warm accent: the site-wide standard for secondary-button hover and
     text-field focus (Arkiv + Øveplan opt out). Sourced from the Budget
     "Rediger" hover the design settled on. */
  --accent-warm:      #d8b878;                /* hover/focus border */
  --accent-warm-fill: #f6ecd8;                /* hover background   */
  --accent-warm-text: #9a6700;                /* hover text         */
  --accent-warm-ring: rgba(216, 184, 120, 0.35); /* focus glow      */
}

/* --- Reset & base ---------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Øveplan opt-out of the warm theme ──────────────────────
   Øveplan (schedule.html) deliberately keeps the original flat
   pre-theme look. schedule.html loads this shared stylesheet and
   its transparent .sched-main shows the body through, so we undo
   the warm colours here rather than touching schedule.css.
   All Øveplan overrides live in THIS one block — to let Øveplan
   adopt the warm theme too, just delete the whole block. The
   values below are the site's original pre-theme colours. */
body:has(.sched-layout) {
  background: #ffffff;
  color: #1f2328;
}

body:has(.sched-layout) .site-footer {
  border-top-color: #e5e7eb;
}
/* ───────────────────────────────────────────────────────────── */

/* --- Site header / navigation ---------------------------- */
.site-header {
  background: #1f2328;
  color: #ffffff;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-title {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: #ffffff;
}

.site-nav {
  display: flex;
  gap: 0.25rem;
}

.site-nav a {
  color: #c9d1d9;
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

@media (hover: hover) {
  .site-nav a:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
  }
}

.site-nav a.active {
  background: rgba(255,255,255,0.15);
  color: #ffffff;
  font-weight: 500;
}

.site-nav-locked {
  color: #6e7681;
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  cursor: not-allowed;
  user-select: none;
}

/* --- Login button / modal --------------------------------- */
.site-auth {
  margin-left: auto;
}

.site-login-btn {
  background: rgba(255,255,255,0.1);
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

@media (hover: hover) {
  .site-login-btn:hover {
    background: rgba(255,255,255,0.2);
  }
}

.site-gate-login {
  background: #3b82d4;
  border: none;
  margin-top: 0.5rem;
}

@media (hover: hover) {
  .site-gate-login:hover {
    background: #2f6cb3;
  }
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.login-modal {
  background: var(--surface);
  border-radius: 8px;
  padding: 1.5rem;
  width: min(340px, 90vw);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.login-modal h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.login-modal p {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.login-modal input[type="password"] {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}

.login-error {
  color: #c0392b;
  font-size: 0.82rem;
  min-height: 1.2em;
  margin-top: 0.4rem;
}

.login-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.site-btn-primary,
.site-btn-secondary,
.site-btn-warm {
  border-radius: 6px;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
}

.site-btn-primary {
  background: #3b82d4;
  color: #ffffff;
  border: none;
}

@media (hover: hover) {
  .site-btn-primary:hover { background: #2f6cb3; }
}
.site-btn-primary:disabled { opacity: 0.6; cursor: default; }

.site-btn-secondary {
  background: #ffffff;
  color: #1f2328;
  border: 1px solid #d0d7de;
}

@media (hover: hover) {
  .site-btn-secondary:hover {
    background: var(--accent-warm-fill);
    border-color: var(--accent-warm);
    color: var(--accent-warm-text);
  }
}

/* Warm secondary button — the site's standard warm-amber look
   (mirrors .btn-small), used for "Annuller" next to a blue primary. */
.site-btn-warm {
  background: #fdf8ec;
  color: var(--text);
  border: 1px solid var(--border);
}

@media (hover: hover) {
  .site-btn-warm:hover {
    background: var(--accent-warm-fill);
    border-color: var(--accent-warm);
    color: var(--accent-warm-text);
  }
}

/* --- Mobile menu (hamburger + overlay) --------------------
   z-index ladder: header 100 → menu overlay 150 → login/edit
   modals 200. The hamburger is hidden on desktop (≥720px). */
.site-menu-btn {
  display: none; /* shown ≤719px */
  flex-direction: column;
  justify-content: space-between;
  width: 44px;
  height: 44px;
  padding: 14px 10px;
  background: none;
  border: none;
  cursor: pointer;
  margin-left: auto;
}

.site-menu-bar {
  display: block;
  height: 2px;
  width: 100%;
  background: #ffffff;
  border-radius: 1px;
}

.site-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: #1f2328;
  display: flex;
  flex-direction: column;
  padding: 0 1.25rem 1.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.site-menu-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  flex-shrink: 0;
}

.site-menu-close {
  background: none;
  border: none;
  color: #c9d1d9;
  font-size: 1.4rem;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  outline: none;
}

.site-menu-close:focus-visible {
  outline: 2px solid #3b82d4;
}

.site-menu-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 1rem;
}

.site-menu-nav a {
  color: #c9d1d9;
  text-decoration: none;
  font-size: 1.25rem;
  padding: 0.75rem 0.5rem;
  border-radius: 6px;
}

.site-menu-nav a.active {
  background: rgba(255,255,255,0.15);
  color: #ffffff;
  font-weight: 500;
}

.site-menu-nav .site-nav-locked {
  color: #6e7681;
  font-size: 1.25rem;
  padding: 0.75rem 0.5rem;
  cursor: not-allowed;
  user-select: none;
}

.site-menu-auth {
  margin-top: auto;
  padding-top: 1.5rem;
}

.site-menu-auth .site-login-btn {
  width: 100%;
  padding: 0.7rem 1rem;
  font-size: 1rem;
}

body.site-menu-open {
  overflow: hidden;
}

/* --- Main content ---------------------------------------- */
.page-content {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page-content h1 {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.page-content h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

/* --- Card ------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.card ul {
  padding-left: 1.2rem;
}

/* --- Edit modal (site-utils.js siteOpenEditModal) --------- */
.edit-modal {
  width: min(480px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
}

.edit-field {
  margin-bottom: 0.75rem;
}

.edit-field label {
  display: block;
  font-size: 0.8rem;
  color: #57606a;
  margin-bottom: 0.25rem;
}

.edit-field input,
.edit-field textarea,
.edit-field select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #ffffff;
  color: #1f2328;
}

.edit-field textarea {
  min-height: 90px;
  resize: vertical;
}

/* Warm focus is the site-wide standard for text fields (Arkiv opts out in
   archive.css; Øveplan styles its own fields in schedule.css). */
.edit-field input:focus,
.edit-field select:focus,
.edit-field textarea:focus,
.login-modal input[type="password"]:focus {
  outline: none;
  border-color: var(--accent-warm);
  box-shadow: 0 0 0 2px var(--accent-warm-ring);
}

.edit-field-row {
  display: flex;
  gap: 0.75rem;
}

.edit-field-row > .edit-field {
  flex: 1;
}

.edit-actions-left {
  margin-right: auto;
}

/* --- Card header + small admin buttons -------------------- */
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.card-head h2 {
  margin-bottom: 0;
}

.btn-small {
  background: #fdf8ec;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

@media (hover: hover) {
  .btn-small:not(.btn-small-danger):hover {
    background: var(--accent-warm-fill);
    border-color: var(--accent-warm);
    color: var(--accent-warm-text);
  }
}

.btn-small-danger {
  color: #c0392b;
  border-color: #e0b4ae;
}

@media (hover: hover) {
  .btn-small-danger:hover { background: #fbf1f0; }
}

/* --- Messages -------------------------------------------- */
.message-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  border-left: 3px solid #3b82d4;
  padding-left: 0.75rem;
}

.message-meta {
  font-size: 0.8rem;
  color: #57606a;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.message-badge {
  background: #eaf1fb;
  color: #2f6cb3;
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
  font-size: 0.72rem;
  white-space: nowrap;
}

/* --- Footer ---------------------------------------------- */
.site-footer {
  text-align: center;
  padding: 1.25rem;
  font-size: 0.8rem;
  color: #57606a;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* --- Utility --------------------------------------------- */
p {
  color: #57606a;
  margin-bottom: 0.5rem;
}

p:last-child {
  margin-bottom: 0;
}

/* --- Mobile (≤719px) --------------------------------------
   Breakpoint: 719px — keep in sync with calendar.css/schedule.css. */
@media (max-width: 719px) {
  .site-header {
    padding: 0 0.75rem 0 1rem;
    gap: 1rem;
  }

  /* Inline nav + login collapse into the hamburger menu.
     Scoped to .site-header so the overlay's own nav is unaffected. */
  .site-header .site-nav,
  .site-header .site-auth {
    display: none;
  }

  .site-menu-btn {
    display: flex;
  }

  .page-content {
    padding: 1.25rem 1rem;
  }

  /* iOS Safari zooms into focused inputs with font-size < 16px. */
  .login-modal input[type="password"],
  .edit-field input,
  .edit-field textarea,
  .edit-field select {
    font-size: 16px;
  }
}
