/* ============================================
   MAIN STYLES - Global & Shared
   ============================================ */

:root {
  /* D&D Beyond Colors */
  --primary-red: #C53131;
  --primary-red-dark: #A02828;
  --primary-red-light: #E54545;

  --dark-bg: #1C1C1E;
  --darker-bg: #121214;
  --light-bg: #F5F5F5;
  --white: #FFFFFF;

  --text-primary: #333333;
  --text-secondary: #666666;
  --text-light: #999999;
  --text-white: #FFFFFF;

  --accent-blue: #4A90D9;
  --accent-green: #4CAF50;
  --accent-gold: #FFD700;
  --accent-purple: #9C27B0;

  --border-color: #E0E0E0;
  --border-dark: #333333;

  /* Proficiency colors */
  --proficient: #333333;
  --expertise: #C53131;

  /* Typography */
  --font-primary: 'Alegreya', Georgia, serif;
  --font-display: 'Cinzel', Georgia, serif;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.15);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ============================================
   PARCHMENT & INK — Design Tokens
   ============================================ */
:root {
  /* Parchment & Ink tokens */
  --desk:#241a12; --parchment:#efe1be; --panel:#f7eed8;
  --panel-border:#c7af7e; --panel-ring:#e0cd9e; --tile-border:#b49254;
  --ink:#2f2114; --body-ink:#4a3a22;
  --oxblood:#58180d; --oxblood-hi:#63200f; --oxblood-lo:#4a130a; --red-hover:#7a2e1d;
  --gold:#9a7b36; --gold-bright:#c9a85c; --gold-pale:#e9cf96; --gold-chip:#d8b878;
  --gold-max:#f4e3b6; --gold-dim:#c8a367; --label:#7a5c25; --dot-rule:#d9c491;
  --note-blue:#3e5a8c; --note-red:#a33b2e;
  --font-body:'Alegreya', Georgia, serif;
  --font-sc:'Alegreya Sans SC', sans-serif;
  --font-note:'Caveat', cursive;
  --grain:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-body);
  background: radial-gradient(ellipse 100% 60% at 50% -10%, rgba(154,123,54,.18), transparent 60%), var(--desk);
  color: var(--ink);
  padding: 14px 14px 44px;
  display: flex; flex-direction: column; align-items: center;
}
html[data-view="classic"] body.has-classic { background: var(--light-bg); display: block; padding: 0; }

.sheet {
  width: 1220px; min-width: 1220px; position: relative;
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(255,248,224,.5), transparent 70%),
    radial-gradient(ellipse 80% 50% at 100% 100%, rgba(120,84,30,.14), transparent 65%),
    var(--grain), var(--parchment);
  border: 3px double var(--gold);
  box-shadow: inset 0 0 70px rgba(120,84,30,.22), 0 10px 40px rgba(0,0,0,.5);
  color: var(--ink);
}
/* Fixed 1.1× "charmed" zoom (spec 2026-07-19): JS sets --sheet-zoom to
   clamp(1, clientWidth/1248, 1.1); default 1 keeps today's look without JS.
   Scoped to D&D view so Classic CV stays unzoomed. */
html[data-view="dnd"] body { zoom: var(--sheet-zoom, 1); }

html[data-view="classic"] body.has-classic .sheet {
  width: auto; min-width: 0; background: none; border: none; box-shadow: none;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-red);
}

/* Utility Classes */
.clickable {
  cursor: pointer;
  transition: all var(--transition-fast);
}

.clickable:hover {
  opacity: 0.8;
}

.editable {
  position: relative;
}

.editable[contenteditable="true"] {
  outline: 2px dashed var(--accent-blue);
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}

/* ============================================
   NAV BAND
   Note: `#mainNavbar`-scoped selectors below (and `.sheet .contact-bar` further
   down) intentionally target the id/`.sheet` ancestor rather than the bare
   `.navbar`/`.contact-bar`/`.rest-btn` class alone. css/character-sheet.css
   (loaded after this file on every page) still defines those same class names
   with the old dark theme; a bare-class rule here would tie in specificity
   and lose to the later stylesheet. Scoping wins the cascade without editing
   character-sheet.css, which is out of scope for this task (Tasks 2/3/5 own
   it). A later cleanup task can remove the legacy rules there and simplify
   these back down to the bare class names.
   A few rules below also restate a property (e.g. `background: none` on
   `.nav-link:hover`/`.nav-link.active`, `background`/`color` on the rest-btn
   `:hover` states, `justify-content: flex-start` on `#mainNavbar` itself)
   purely to neutralize an old character-sheet.css property this file doesn't
   otherwise compete on, which would apply unopposed regardless of specificity
   (e.g. a stray red pill on the active nav-link, a sky-blue Long Rest hover,
   `justify-content:space-between` flinging the hamburger toggle to the far
   right of the 1220px bar once `.nav-d20` became a second always-visible flex
   child below the 992px breakpoint) — verified against headless-Chrome
   screenshots and computed-style/getBoundingClientRect introspection of this
   page.
   ============================================ */
#mainNavbar {
  display: flex; align-items: center; gap: 14px; justify-content: flex-start;
  background: linear-gradient(180deg, var(--oxblood-hi), var(--oxblood) 60%, var(--oxblood-lo));
  padding: 10px 16px; border-bottom: 2px solid var(--gold); white-space: nowrap;
}
.nav-d20 {
  flex: none; width: 24px; height: 26px;
  clip-path: polygon(25% 5%,75% 5%,100% 50%,75% 95%,25% 95%,0 50%);
  background: var(--gold-bright); display: flex; align-items: center; justify-content: center;
  font: 700 10px var(--font-display); color: var(--oxblood-lo);
}
#mainNavbar .navbar-left { display: flex; gap: 13px; align-items: center; }
#mainNavbar .nav-link {
  font: 700 10px var(--font-sc); letter-spacing: .1em; color: var(--gold-chip);
  text-decoration: none; padding: 0 0 2px;
}
#mainNavbar .nav-link:hover { color: var(--gold-max); background: none; }
#mainNavbar .nav-link.active { color: var(--gold-max); border-bottom: 2px solid var(--gold-bright); background: none; }
#mainNavbar .navbar-right { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.campaign-status { font: 500 9px var(--font-sc); letter-spacing: .08em; color: var(--gold-dim); cursor: pointer; }
.campaign-status .campaign-name { color: var(--gold-max); }
#mainNavbar .rest-btn { border: none; cursor: pointer; border-radius: 2px; font: 700 9px var(--font-sc); letter-spacing: .08em; }
.rest-btn.short-rest { color: var(--oxblood-lo); background: var(--gold-chip); padding: 4px 8px; }
.rest-btn.short-rest:hover { background: var(--gold-pale); color: var(--oxblood-lo); }
.rest-btn.long-rest { color: var(--gold-chip); background: transparent; border: 1px solid var(--gold); padding: 3px 8px; }
.rest-btn.long-rest:hover { color: var(--gold-max); background: transparent; }
.view-toggle { display: flex; border: 1px solid var(--gold); border-radius: 2px; overflow: hidden; background: none; box-shadow: none; padding: 0; margin-left: 0; }
.view-toggle-btn { font: 700 9px var(--font-sc); letter-spacing: .06em; color: var(--gold-dim); padding: 4px 7px; background: transparent; border: none; border-radius: 0; cursor: pointer; }
.view-toggle-btn:hover { color: var(--gold-max); background: transparent; }
.view-toggle-btn.active { background: var(--gold-bright); color: var(--oxblood-lo); }
/* Centered page name shown only in the ≤740px nav band (Task 6); one span per
   page ("Character Sheet"/"Campaign Journal"/etc.), added as a direct child
   of #mainNavbar alongside .nav-d20/.navbar-toggle/.navbar-menu. */
.navbar-page-title { display: none; }

/* Footer contact band */
.sheet .contact-bar {
  display: flex; justify-content: center; gap: 26px;
  background: linear-gradient(180deg, var(--oxblood-hi), var(--oxblood-lo));
  border-top: 2px solid var(--gold); padding: 9px 20px;
  font: 600 10.5px var(--font-sc); letter-spacing: .12em;
}
.contact-bar a, .contact-bar .contact-item { color: var(--gold-chip); display: inline-flex; gap: 5px; align-items: center; font-size: inherit; }
.contact-bar a:hover { color: var(--gold-max); }

/* Panel + section title (restyle existing class names) */
.section-box {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 0;
  box-shadow: inset 0 0 0 3px var(--panel), inset 0 0 0 4px var(--panel-ring);
  padding: 12px 14px; margin-bottom: 0;
}
.section-title {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  font: 700 10px var(--font-sc); letter-spacing: .2em; color: var(--oxblood);
  text-transform: none; border-bottom: none; padding-bottom: 0;
}
.section-title::before, .section-title::after { content: ''; flex: 1; height: 1px; background: var(--panel-border); }

/* Page header (content pages) */
.page-head { text-align: center; padding: 30px 26px 6px; }
.page-kicker { font: 700 9.5px var(--font-sc); letter-spacing: .3em; color: var(--label); }
.page-title { font: 700 36px var(--font-display); color: var(--oxblood); text-shadow: 0 1px 0 rgba(255,248,224,.6); margin-top: 4px; }
.page-rule { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 8px; color: var(--gold); font-size: 11px; }
.page-rule::before { content: ''; width: 120px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.page-rule::after  { content: ''; width: 120px; height: 1px; background: linear-gradient(90deg, var(--gold), transparent); }
.page-sub { font: 500 14px var(--font-body); font-style: italic; color: var(--body-ink); margin-top: 8px; }

/* Chips */
.chip-tag { font: 500 11.5px var(--font-body); border: 1px solid var(--tile-border); background: var(--parchment); padding: 2px 10px; border-radius: 10px; }
.chip-red { font: 600 11.5px var(--font-body); color: var(--gold-max); background: var(--oxblood); border: 1px solid var(--gold); padding: 2px 10px; border-radius: 10px; }

/* Rotated-square proficiency pip (restyles existing .proficiency-marker) */
.proficiency-marker { width: 7px; height: 7px; border: 1px solid var(--oxblood); border-radius: 0; transform: rotate(45deg); margin-right: 0; }
.proficiency-marker.filled,
.proficiency-marker.expertise,
.skill-item.expertise .proficiency-marker.expertise {
  background: var(--oxblood);
  border-color: var(--oxblood);
}

/* Margin notes */
.margin-note { position: absolute; font: 600 15px var(--font-note); color: var(--note-blue); white-space: nowrap; pointer-events: none; z-index: 5; }
.margin-note--red { color: var(--note-red); }

/* Rollable: parchment highlight instead of emoji */
.rollable { cursor: pointer; padding: 0 4px; border-radius: 3px; }
.rollable:hover { background: var(--parchment); color: inherit; transform: none; }
.rollable::after { content: none; }

/* Admin Login Button (fixed-position mechanics kept; glyph + parchment skin) */
.admin-login-btn {
  position: fixed;
  bottom: var(--spacing-md);
  right: var(--spacing-md);
  z-index: 1000;
  width: 40px;
  height: 40px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  border-radius: 50%;
  cursor: pointer;
  color: var(--label);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  opacity: 0.5;
  transition: all var(--transition-fast);
}

.admin-login-btn:hover {
  opacity: 1;
  transform: rotate(90deg);
}

/* Admin Mode Indicator */
body.admin-mode::before {
  content: 'ADMIN MODE';
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: var(--oxblood);
  color: var(--gold-max);
  padding: var(--spacing-xs) var(--spacing-md);
  font: 700 11px var(--font-sc);
  letter-spacing: .14em;
  border: 1px solid var(--gold);
  border-top: none;
  border-radius: 0 0 4px 4px;
  z-index: 10000;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--desk);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-bright);
}

/* Modal Base Styles */
.overlay-modal,
.dice-modal,
.admin-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.overlay-modal.active,
.dice-modal.active,
.admin-modal.active {
  display: flex;
  opacity: 1;
}

/* Close Button */
.overlay-close,
.admin-close {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1;
  z-index: 10; /* Ensure close button is above other elements */
}

.overlay-close:hover,
.admin-close:hover {
  color: var(--primary-red);
  transform: rotate(90deg);
}

/* ============================================
   ADMIN MODAL — parchment panel restyle
   (.overlay-close itself is hidden via css/overlay.css — the band ✕ replaces
   it there; .admin-close keeps the mechanics above, just restyled below.)
   ============================================ */
.admin-modal { background: rgba(20,12,6,.74); }
.admin-close { color: var(--label); }
.admin-close:hover { color: var(--oxblood); transform: rotate(90deg); }

.admin-content {
  width: 340px; max-width: 90vw;
  background: var(--grain), var(--panel);
  border: 3px double var(--gold);
  box-shadow: inset 0 0 40px rgba(120,84,30,.18), 0 24px 70px rgba(0,0,0,.65);
  padding: 30px 26px 24px;
  position: relative;
  animation: pi-fadeup .25s;
}
.admin-content h2 {
  font: 700 19px var(--font-display); color: var(--oxblood);
  text-align: center; margin-bottom: 18px;
}
.admin-content input[type="password"] {
  display: block; width: 100%;
  font: 500 14px var(--font-body); color: var(--ink);
  background: var(--parchment); border: 1px solid var(--panel-border);
  padding: 9px 12px; border-radius: 2px; margin-bottom: 14px;
}
.admin-content input[type="password"]:focus { outline: none; border-color: var(--gold); }
.admin-content button[type="submit"] {
  display: block; width: 100%;
  font: 700 10.5px var(--font-sc); letter-spacing: .14em;
  color: var(--gold-max); background: var(--oxblood); border: 1px solid var(--gold);
  padding: 10px 18px; border-radius: 2px; cursor: pointer;
}
.admin-content button[type="submit"]:hover { background: #6b2413; }
@media (prefers-reduced-motion: reduce) {
  .admin-content { animation: none; }
}

/* Loading State */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-red);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Shared modal/overlay entrance keyframes (T12 dedup): previously redefined
   identically in css/dice.css, css/overlay.css, css/campaigns.css and
   css/projects.css. main.css loads on all 6 pages ahead of every other
   stylesheet, so a single definition here now serves every caller
   (.admin-content here, .overlay-content/.campaign-body/.project-card in
   their own files, .dice-result/.dice-card/.total-stamp in dice.css). */
@keyframes pi-fadeup { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:none} }
@keyframes pi-slideup { from{transform:translateY(100%)} to{transform:none} }

/* Responsive Breakpoints */
@media (max-width: 1200px) {
  :root {
    font-size: 15px;
  }
}

@media (max-width: 992px) {
  :root {
    font-size: 14px;
  }
}

@media (max-width: 768px) {
  .admin-login-btn {
    bottom: 120px;
  }
}

/* ============================================
   MOBILE NAV (≤740px) — Task 6
   #mainNavbar-scoped for the same reason as the NAV BAND rules above:
   css/character-sheet.css's unconditional (non-media) hamburger-icon geometry
   (.navbar-toggle-icon and its ::before/::after) loads AFTER this file and
   ties in specificity with a bare-class override, so it would win regardless
   of this block's own source order. An ID-anchored selector beats that bare
   class regardless of load order — same fix Task 1 already applied elsewhere.
   The sheet/header/vitals/accordion/quick-bar mobile layer itself lives in
   css/character-sheet.css's own ≤740px block (Task 6 Step 2/4/5); this block
   is nav-dropdown + admin-button only, per this task's file split.
   ============================================ */
@media (max-width: 740px) {
  #mainNavbar { flex-wrap: wrap; position: relative; padding: 13px 16px; }

  /* Hamburger: visible, gold bars (17x2px, third 11px) replacing the old
     22px-equal-bar / dark-dropdown treatment entirely. */
  #mainNavbar .navbar-toggle { display: flex; order: 1; }
  #mainNavbar .navbar-toggle-icon { width: 17px; background: var(--gold-chip); }
  #mainNavbar .navbar-toggle-icon::before { width: 17px; top: -5px; background: var(--gold-chip); }
  #mainNavbar .navbar-toggle-icon::after { width: 11px; top: 5px; background: var(--gold-chip); }
  #mainNavbar.is-open .navbar-toggle-icon { background: transparent; }
  #mainNavbar.is-open .navbar-toggle-icon::before,
  #mainNavbar.is-open .navbar-toggle-icon::after { top: 0; }

  /* Centered page name */
  .navbar-page-title { display: block; order: 2; flex: 1; text-align: center; font: 700 11px var(--font-sc); letter-spacing: .22em; color: var(--gold-max); }

  /* d20 mark: right edge */
  #mainNavbar .nav-d20 { order: 3; }

  /* Dropdown: red/gold band (not the old dark-bg), stacked links + chips/
     buttons/toggle folded in below the links, one full-width column. */
  #mainNavbar .navbar-menu {
    order: 4; display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex: none; flex-direction: column; align-items: stretch; gap: 0;
    background: linear-gradient(180deg, var(--oxblood), var(--oxblood-lo));
    border-top: 1px solid var(--gold); border-bottom: 2px solid var(--gold);
    box-shadow: 0 14px 30px rgba(0,0,0,.45);
    max-height: calc(100vh - 54px); overflow-y: auto; z-index: 150;
  }
  #mainNavbar.is-open .navbar-menu { display: flex; }
  #mainNavbar .navbar-left { flex-direction: column; align-items: stretch; gap: 0; padding: 8px 16px; }
  #mainNavbar .navbar-left .nav-link { padding: 12px 0; font-size: 12px; letter-spacing: .14em; text-align: center; border-bottom: 1px solid rgba(201,168,92,.25); }
  #mainNavbar .navbar-left .nav-link:last-child { border-bottom: none; }
  #mainNavbar .navbar-right {
    margin-left: 0; flex-direction: column; align-items: stretch; gap: 8px;
    padding: 12px 16px 16px; border-top: 1px solid rgba(201,168,92,.25);
  }
  #mainNavbar .campaign-status { justify-content: center; text-align: center; }
  #mainNavbar .rest-btn { width: 100%; text-align: center; padding: 11px 0; }
  #mainNavbar .view-toggle { align-self: stretch; margin-left: 0; }
  #mainNavbar .view-toggle-btn { flex: 1; padding: 11px 0; }

  /* index.html now has a fixed ~44px quick bar at the very bottom ≤740px;
     the admin button is a shared fixed element on all 6 pages, simplest to
     raise it consistently rather than special-case it per page. */
  .admin-login-btn { bottom: 60px; }
}
