/* ==========================================================================
   Class VI Study Pack — shared stylesheet
   Social Science · Chapter 1 · Locating Places on Earth
   ========================================================================== */

:root {
  --bg:        #f7f8fb;
  --surface:   #ffffff;
  --surface-2: #eef1f7;
  --border:    #d9dee9;
  --text:      #1a1d26;
  --text-soft: #5b6376;
  --text-faint:#8b93a7;

  --accent:      #4338ca;
  --accent-soft: #eef0fe;
  --accent-line: #c7cbf7;

  --teal:      #0f766e;
  --teal-soft: #e6f4f1;
  --amber:     #a16207;
  --amber-soft:#fdf6e3;
  --rose:      #b91c1c;
  --rose-soft: #fdeaea;
  --green:     #15803d;
  --green-soft:#e8f6ec;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,25,40,.05), 0 4px 16px rgba(20,25,40,.05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

[data-theme="dark"] {
  --bg:        #14161c;
  --surface:   #1c1f27;
  --surface-2: #23262f;
  --border:    #333845;
  --text:      #e8eaf0;
  --text-soft: #a8b0c2;
  --text-faint:#7b8397;

  --accent:      #a5b4fc;
  --accent-soft: #262a3d;
  --accent-line: #3d4463;

  --teal:      #5eead4;
  --teal-soft:  #1a2b2b;
  --amber:     #fcd34d;
  --amber-soft: #2b2519;
  --rose:      #fca5a5;
  --rose-soft:  #2d1d1e;
  --green:     #86efac;
  --green-soft: #1b2a20;

  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: .9rem;
  padding: .6rem 1.1rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-weight: 700; font-size: .95rem; letter-spacing: -.01em;
  display: flex; align-items: center; gap: .5rem;
}
.topbar .brand span { color: var(--accent); }
.topbar nav { margin-left: auto; display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a {
  color: var(--text-soft); text-decoration: none;
  font-size: .84rem; font-weight: 500;
  padding: .35rem .6rem; border-radius: 7px;
}
.topbar nav a:hover { background: var(--surface-2); color: var(--text); }
.topbar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.icon-btn {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-soft); cursor: pointer;
  width: 34px; height: 34px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 1.6rem 1.1rem 5rem; }
.wrap.narrow { max-width: 820px; }

.pagehead { margin: .4rem 0 1.8rem; }
.pagehead .eyebrow {
  font-size: .74rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--accent); margin-bottom: .5rem;
}
.pagehead h1 {
  margin: 0 0 .5rem; font-size: clamp(1.55rem, 3.4vw, 2.1rem);
  letter-spacing: -.02em; line-height: 1.2;
}
.pagehead p { margin: 0; color: var(--text-soft); font-size: .95rem; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.15rem 1.3rem;
  margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card > :first-child { margin-top: 0; }
.card > :last-child  { margin-bottom: 0; }

.grid { display: grid; gap: 1rem; }
.grid.two   { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.four  { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* ---------- hub tiles ---------- */
.tile {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem;
  box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--accent-line); }
.tile .ic { font-size: 1.6rem; line-height: 1; margin-bottom: .6rem; }
.tile h3 { margin: 0 0 .3rem; font-size: 1.02rem; }
.tile p  { margin: 0; font-size: .87rem; color: var(--text-soft); }
.tile .meta {
  margin-top: .7rem; font-size: .76rem; font-weight: 600;
  color: var(--accent); text-transform: uppercase; letter-spacing: .05em;
}

/* ---------- typography ---------- */
h2 {
  font-size: 1.28rem; letter-spacing: -.015em;
  margin: 2.2rem 0 .8rem; padding-bottom: .4rem;
  border-bottom: 2px solid var(--accent-line);
}
h3 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
h4 { font-size: .93rem; margin: 1.1rem 0 .4rem; color: var(--text-soft);
     text-transform: uppercase; letter-spacing: .06em; }
p { margin: .7rem 0; }
a { color: var(--accent); }
ul, ol { padding-left: 1.35rem; margin: .7rem 0; }
li { margin: .3rem 0; }
strong { font-weight: 650; }
code {
  font-family: var(--mono); font-size: .86em;
  background: var(--surface-2); padding: .1em .38em; border-radius: 4px;
}
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

blockquote {
  margin: 1rem 0; padding: .7rem 1rem;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0; color: var(--text);
}
blockquote > :first-child { margin-top: 0; }
blockquote > :last-child { margin-bottom: 0; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--border);
         vertical-align: top; }
th { background: var(--surface-2); font-weight: 650; font-size: .82rem;
     text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); }
tbody tr:hover { background: var(--surface-2); }
td:first-child { font-weight: 550; }

/* ---------- callouts ---------- */
.note { border-radius: 8px; padding: .8rem 1rem; margin: 1rem 0; font-size: .9rem;
        border-left: 3px solid; }
.note.tip   { background: var(--teal-soft);  border-color: var(--teal); }
.note.warn  { background: var(--amber-soft); border-color: var(--amber); }
.note.key   { background: var(--accent-soft);border-color: var(--accent); }
.note.err   { background: var(--rose-soft);  border-color: var(--rose); }
.note > :first-child { margin-top: 0; } .note > :last-child { margin-bottom: 0; }
.note .lbl { font-weight: 700; font-size: .74rem; letter-spacing: .08em;
             text-transform: uppercase; display: block; margin-bottom: .3rem; }
.note.tip  .lbl { color: var(--teal); }
.note.warn .lbl { color: var(--amber); }
.note.key  .lbl { color: var(--accent); }
.note.err  .lbl { color: var(--rose); }

/* ---------- collapsibles ---------- */
details.acc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: .65rem; overflow: hidden;
}
details.acc > summary {
  cursor: pointer; padding: .85rem 1.1rem; font-weight: 600; font-size: .98rem;
  list-style: none; display: flex; align-items: center; gap: .6rem;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::before {
  content: "▸"; color: var(--accent); font-size: .85rem;
  transition: transform .18s; flex-shrink: 0;
}
details.acc[open] > summary::before { transform: rotate(90deg); }
details.acc > summary:hover { background: var(--surface-2); }
details.acc .body { padding: 0 1.1rem 1.1rem; border-top: 1px solid var(--border);
                    padding-top: .9rem; }
details.acc .body > :first-child { margin-top: 0; }
details.acc .num {
  background: var(--accent-soft); color: var(--accent);
  font-size: .74rem; font-weight: 700; padding: .12rem .45rem;
  border-radius: 5px; flex-shrink: 0;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font-family: inherit; font-size: .9rem; font-weight: 600;
  padding: .6rem 1.15rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  text-decoration: none; transition: background .13s, border-color .13s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .btn.primary { color: #14161c; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.big { font-size: 1rem; padding: .8rem 1.7rem; }
.btnrow { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* ---------- pills / chips ---------- */
.pill {
  display: inline-block; font-size: .74rem; font-weight: 650;
  padding: .18rem .55rem; border-radius: 20px;
  background: var(--surface-2); color: var(--text-soft);
}
.pill.a { background: var(--accent-soft); color: var(--accent); }
.pill.g { background: var(--green-soft);  color: var(--green); }
.pill.r { background: var(--rose-soft);   color: var(--rose); }
.pill.t { background: var(--teal-soft);   color: var(--teal); }

.chipbar { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1rem 0; }
.chip {
  font-family: inherit; font-size: .82rem; font-weight: 550;
  padding: .35rem .8rem; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .chip.on { color: #14161c; }

/* ---------- search ---------- */
.search {
  width: 100%; font-family: inherit; font-size: .95rem;
  padding: .65rem .9rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.search:focus { outline: 2px solid var(--accent-line); outline-offset: 1px; }

/* ---------- diagram / ascii ---------- */
pre.diagram {
  font-family: var(--mono); font-size: .78rem; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 1rem; overflow-x: auto; margin: 1rem 0;
  color: var(--text);
}

/* ---------- flashcards ---------- */
.fc-deck { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(250px,1fr)); }
.fc {
  display: block; position: relative;
  perspective: 1200px; height: 190px; cursor: pointer; border: 0;
  background: none; padding: 0; font-family: inherit; text-align: left;
}
/* NB: .fc-inner and .fc-face are <span>s, because a <button> may only contain
   phrasing content. Inline elements ignore width/height, so size them with
   position:absolute + inset:0 instead — that also blockifies them, which
   transform-style:preserve-3d needs in order to work. */
.fc-inner {
  display: block; position: absolute; inset: 0;
  transform-style: preserve-3d; transition: transform .5s cubic-bezier(.4,.2,.2,1);
}
.fc.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; display: flex; flex-direction: column;
  box-shadow: var(--shadow); overflow: auto;
}
.fc-front { background: var(--surface); }
.fc-back  { background: var(--accent-soft); transform: rotateY(180deg);
            border-color: var(--accent-line); }
.fc-face .n { font-size: .7rem; font-weight: 700; color: var(--text-faint);
              letter-spacing: .06em; margin-bottom: .5rem; }
.fc-face .q { font-size: .95rem; font-weight: 600; margin: auto 0; }
.fc-face .a { font-size: .89rem; margin: auto 0; }
.fc-face .hint { font-size: .7rem; color: var(--text-faint); margin-top: .5rem; }

/* ---------- progress ---------- */
.bar { height: 7px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0;
           transition: width .3s; border-radius: 20px; }

/* ---------- quiz ---------- */
.qmeta { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
         margin-bottom: .9rem; font-size: .85rem; color: var(--text-soft); }
.qmeta .grow { margin-left: auto; }
.qnum { font-weight: 700; color: var(--accent); }

.qtext { font-size: 1.12rem; font-weight: 600; line-height: 1.5; margin: .4rem 0 1.2rem; }

.opts { display: grid; gap: .55rem; }
.opt {
  display: flex; align-items: flex-start; gap: .7rem; width: 100%;
  font-family: inherit; font-size: .96rem; text-align: left; line-height: 1.5;
  padding: .8rem 1rem; border-radius: 9px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  transition: border-color .12s, background .12s;
}
.opt:hover:not(:disabled) { border-color: var(--accent-line); background: var(--surface-2); }
.opt .key {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-soft);
  font-size: .78rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .key { background: var(--accent); color: #fff; }
[data-theme="dark"] .opt.sel .key { color: #14161c; }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.right .key { background: var(--green); color: #fff; }
.opt.wrong { border-color: var(--rose); background: var(--rose-soft); }
.opt.wrong .key { background: var(--rose); color: #fff; }
.opt:disabled { cursor: default; }

.dots { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 1.2rem; }
.dot {
  width: 22px; height: 22px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  font-size: .68rem; font-weight: 650; color: var(--text-faint);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit; padding: 0;
}
.dot:hover { border-color: var(--accent); }
.dot.done { background: var(--accent-soft); color: var(--accent);
            border-color: var(--accent-line); }
.dot.here { outline: 2px solid var(--accent); outline-offset: 1px; }
.dot.ok   { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.dot.no   { background: var(--rose-soft);  color: var(--rose);  border-color: var(--rose); }

.scorehero { text-align: center; padding: 1.6rem 1rem; }
.scorehero .big {
  font-size: clamp(2.8rem, 9vw, 4.2rem); font-weight: 800;
  letter-spacing: -.03em; line-height: 1; color: var(--accent);
}
.scorehero .sub { color: var(--text-soft); font-size: .95rem; margin-top: .4rem; }
.scorehero .verdict { font-size: 1.1rem; font-weight: 650; margin-top: .9rem; }

.statgrid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit,minmax(120px,1fr));
            margin: 1.3rem 0; }
.stat { background: var(--surface-2); border-radius: 9px; padding: .8rem; text-align: center; }
.stat .v { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: .74rem; color: var(--text-soft); text-transform: uppercase;
           letter-spacing: .05em; margin-top: .2rem; }
.stat.ok .v { color: var(--green); }
.stat.no .v { color: var(--rose); }

.review { margin-top: 1.4rem; }
.rev-item {
  border: 1px solid var(--border); border-left: 3px solid;
  border-radius: 8px; padding: .95rem 1.1rem; margin-bottom: .7rem;
  background: var(--surface);
}
.rev-item.ok { border-left-color: var(--green); }
.rev-item.no { border-left-color: var(--rose); }
.rev-item .rq { font-weight: 600; font-size: .95rem; margin-bottom: .55rem; }
.rev-item .ra { font-size: .88rem; margin: .2rem 0; }
.rev-item .ra .tag { font-weight: 700; font-size: .72rem; letter-spacing: .05em;
                     text-transform: uppercase; margin-right: .4rem; }
.rev-item .ra.you .tag { color: var(--rose); }
.rev-item .ra.cor .tag { color: var(--green); }
.rev-item .why {
  margin-top: .6rem; padding: .6rem .8rem; border-radius: 7px;
  background: var(--accent-soft); font-size: .87rem;
}
.rev-item .why .tag { font-weight: 700; font-size: .72rem; letter-spacing: .05em;
                      text-transform: uppercase; color: var(--accent); display: block;
                      margin-bottom: .25rem; }

/* ---------- misc ---------- */
.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--text-soft); }
.small { font-size: .86rem; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

footer.foot {
  margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--border);
  font-size: .82rem; color: var(--text-faint); display: flex;
  justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}

@media print {
  .topbar, .btnrow, .chipbar, .icon-btn, footer.foot { display: none !important; }
  body { background: #fff; }
  .card, details.acc { break-inside: avoid; box-shadow: none; }
  details.acc { border: 1px solid #ccc; }
  details.acc:not([open]) > .body { display: block !important; }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .topbar nav { width: 100%; margin-left: 0; }
  .wrap { padding: 1.1rem .8rem 4rem; }
  .fc { height: 210px; }
}
