/* Source colours for the existing inverted Obsidian palette. */
html[data-theme="1"] {
  --paper: #f0e8ed;
  --cinema-glass: linear-gradient(135deg, rgba(224, 204, 216, .94), rgba(231, 215, 224, .92));
  --cinema-border: rgba(155, 116, 140, .58);
  --cinema-light: rgba(159, 100, 130, .14);
}
html[data-theme="1"] body {
  isolation: isolate;
  background: #f0e8ed;
}
.site-atmosphere {
  position: fixed;
  inset: 0;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  display: none;
}
html[data-theme="1"] .site-atmosphere { display: block; }
.site-atmosphere::before {
  content: "";
  position: absolute;
  inset: -40px;
  background:
    radial-gradient(ellipse at var(--light-x, 60%) var(--light-y, 25%), var(--cinema-light), transparent 45%),
    radial-gradient(ellipse at 16% 22%, rgba(112, 158, 147, .24), transparent 42%),
    radial-gradient(ellipse at 86% 65%, rgba(182, 146, 107, .16), transparent 48%);
  transform: translate(var(--drift-x, 0px), var(--drift-y, 0px));
  transition: transform 1.4s ease-out;
}
.site-atmosphere::after {
  content: "";
  position: absolute;
  width: min(72vw, 900px);
  aspect-ratio: 1;
  top: -26%;
  right: -17%;
  border-radius: 50%;
  border: 1px solid rgba(142, 99, 129, .18);
  box-shadow: 0 0 110px 24px rgba(141, 104, 134, .07), inset 0 0 90px rgba(148, 116, 140, .07);
  transform: translate(calc(var(--drift-x, 0px) * -1), calc(var(--drift-y, 0px) * -1)) rotate(-24deg) scaleY(.62);
  transition: transform 1.8s ease-out;
}
html[data-theme="1"] :is(.graph-panel, .inspector-panel, .content-card, .course-card, .session-card, .auth-card) {
  background: var(--cinema-glass);
  border: 1px solid var(--cinema-border);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 16px 46px rgba(130, 101, 119, .09);
}
html[data-theme="1"] .app-header {
  background: rgba(239, 226, 234, .94);
  border-bottom-color: var(--cinema-border);
}
html[data-theme="1"] .sidebar { background: rgba(235, 220, 230, .91); }
html[data-theme="1"] .metric-card {
  background: linear-gradient(120deg, rgba(223, 201, 215, .92), rgba(233, 219, 228, .88));
  border-color: var(--cinema-border);
  border-radius: 14px;
}
html[data-theme="1"] :is(.modal, .concept-context-menu, .theme-menu, .account-menu) {
  background: #e6d2de;
  box-shadow: 0 18px 70px rgba(119, 85, 107, .22);
}
html[data-theme="1"] .graph-stage { background-color: #e7dbe2; }
html[data-theme="1"] .graph-panel:is(:fullscreen, .graph-expanded-fallback) {
  background: linear-gradient(135deg, #e0ccd8, #e7d7e0);
}
html[data-theme="1"] .about-header { max-width: 1120px; padding-top: 1.4rem; }
html[data-theme="1"] .about-page { max-width: 1120px; padding-top: clamp(1.5rem, 5vh, 4rem); }
html[data-theme="1"] .about-page > article {
  position: relative;
  border-radius: 28px;
  padding: clamp(1.6rem, 5vw, 4.5rem);
  transform: perspective(1600px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform 1.2s ease-out;
}
html[data-theme="1"] .about-page h1 {
  max-width: 16ch;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: clamp(2.5rem, 6vw, 5rem);
  line-height: 1.05;
  letter-spacing: -.045em;
}
html[data-theme="1"] .about-page .about-intro { max-width: 52ch; font-size: clamp(1rem, 2vw, 1.2rem); }
@supports (backdrop-filter: blur(12px)) {
  html[data-theme="1"] :is(.app-header, .about-page > article, .auth-card) {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
}
@media (hover: none) {
  :is(button, a.secondary-button, .header-browse-button):active { opacity: .8; }
  html[data-theme="1"] .about-page > article { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .site-atmosphere::before, .site-atmosphere::after { transform: none; transition: none; }
  html[data-theme="1"] .about-page > article { transform: none; transition: none; }
}
@media (max-width: 760px) {
  html[data-theme="1"] .about-page > article { border-radius: 20px; }
  html[data-theme="1"] .about-header { padding-top: .75rem; }
  .site-atmosphere::after { width: 110vw; right: -52%; top: -8%; }
}

/* The scholar's grotto. Colours remain compatible with Obsidian's root inversion. */
html[data-theme="1"] {
  --paper: #f0ede7;
  --cinema-light: rgba(151, 85, 38, .24);
  --cinema-border: rgba(108, 122, 148, .7);
  --cave-wall: url("../assets/images/cave-scholar-wall.webp");
}
html[data-theme="1"] .site-atmosphere {
  background: var(--cave-wall) center / cover no-repeat;
  filter: invert(1);
}
html[data-theme="1"] .site-atmosphere::before {
  background:
    radial-gradient(ellipse at var(--light-x, 55%) var(--light-y, 35%), rgba(150, 209, 181, .17), transparent 38%),
    linear-gradient(90deg, rgba(3, 8, 7, .28), transparent 60%, rgba(1, 6, 8, .12));
}
html[data-theme="1"] .site-atmosphere::after { display: none; }

html[data-theme="1"] .app-header {
  background: rgba(232, 230, 224, .92);
  border-bottom: 3px double #8b99ab;
  box-shadow: 0 5px 18px rgba(126, 135, 143, .2);
}
html[data-theme="1"] .sidebar {
  background: linear-gradient(90deg, rgba(234, 233, 227, .93), rgba(229, 226, 215, .87));
  border-right: 3px double #9aa5b4;
}
html[data-theme="1"] :is(.theme-button, .header-browse-button, .graph-toolbar button) {
  border-radius: 5px 9px 4px 7px;
}
html[data-theme="1"] :is(.page-head h1, .panel-head h2, .region-panel h2, .section-heading h2) {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}
html[data-theme="1"] .page-head h1 { font-size: clamp(2.2rem, 3.5vw, 3.5rem); }
html[data-theme="1"] .page-head > div:first-child {
  padding: .75rem 1rem;
  border-left: 2px solid #778b9f;
  background: linear-gradient(90deg, rgba(230, 224, 207, .91), rgba(230, 224, 207, .4), transparent);
}
html[data-theme="1"] :is(.graph-panel, .inspector-panel, .course-card, .session-card, .content-card, .auth-card) {
  background:
    repeating-linear-gradient(3deg, transparent 0 10px, rgba(105, 125, 139, .025) 10px 11px),
    linear-gradient(118deg, rgba(222, 223, 211, .97), rgba(226, 227, 219, .94));
  border: 1px solid #9eacc0;
  border-radius: 4px 14px 6px 12px;
  box-shadow: 0 0 0 3px rgba(218, 220, 212, .23), 3px 10px 25px rgba(118, 128, 137, .2), inset 0 1px 0 #c7d1df;
}
html[data-theme="1"] :is(.metric-card, .progress-stat) {
  background: linear-gradient(115deg, rgba(210, 216, 216, .96), rgba(225, 228, 219, .92));
  border: 1px solid #91a5b7;
  border-radius: 2px 8px 3px 6px;
  box-shadow: 2px 5px 8px rgba(128, 139, 148, .16);
}
html[data-theme="1"] .metric-card:nth-child(even) { border-top: 3px solid #8a9ba9; }
html[data-theme="1"] .graph-panel { border-top: 5px double #8b9cae; }
html[data-theme="1"] .graph-panel:is(:fullscreen, .graph-expanded-fallback) {
  background: linear-gradient(118deg, #dedfd3, #e2e3db);
}
html[data-theme="1"] .graph-stage {
  background-color: #e1e3db;
  box-shadow: inset 0 0 50px rgba(136, 148, 152, .18);
}
html[data-theme="1"] :is(.concept-node, .region-summary, .iso-node .iso-label, .graph-3d-label) {
  border-radius: 3px 9px 4px 7px;
}
html[data-theme="1"] :is(.graph-panel, .inspector-panel, .course-card, .session-card) .eyebrow {
  letter-spacing: .16em;
}
html[data-theme="1"] .about-header { max-width: 1180px; }
html[data-theme="1"] .about-page { max-width: 1080px; padding-top: clamp(3rem, 7vh, 5rem); padding-bottom: 5rem; }
html[data-theme="1"] .about-page > article {
  --ink: #e0dcd4;
  --muted: #bbb7b0;
  --green: #a29b8d;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(176, 178, 171, .07) 0 1px, transparent 1px 5px),
    linear-gradient(108deg, #243753, #304362 55%, #22334f);
  border: 1px solid #6e7a8d;
  border-radius: 2px 13px 3px 8px;
  box-shadow: 5px 15px 40px rgba(138, 144, 150, .6), inset 0 0 55px rgba(107, 112, 121, .22);
  padding-top: clamp(3rem, 6vw, 5rem);
}
html[data-theme="1"] .about-page > article::before,
html[data-theme="1"] .about-page > article::after {
  content: "";
  position: absolute;
  top: -13px;
  width: 110px;
  height: 30px;
  background: rgba(79, 92, 114, .86);
  border: 1px solid rgba(120, 126, 140, .6);
  box-shadow: 0 2px 3px rgba(75, 82, 95, .15);
  pointer-events: none;
}
html[data-theme="1"] .about-page > article::before { left: 7%; transform: rotate(-9deg); }
html[data-theme="1"] .about-page > article::after { right: 7%; transform: rotate(8deg); }
html[data-theme="1"] .about-page h1 {
  font-size: clamp(2.6rem, 6vw, 4.9rem);
  color: #e1dcd2;
}
html[data-theme="1"] .about-page h2 {
  color: #dad5ca;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}
html[data-theme="1"] .about-page .eyebrow { color: #b3aa9b; }
html[data-theme="1"] :is(.app-header, .about-page > article, .auth-card) {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
@media (max-width: 760px) {
  html[data-theme="1"] .about-page > article { border-radius: 2px 9px 3px 6px; }
  html[data-theme="1"] .site-atmosphere { background-position: 65% center; }
  html[data-theme="1"] .about-page > article::before,
  html[data-theme="1"] .about-page > article::after { width: 70px; }
  html[data-theme="1"] .sidebar { border-right: 0; border-top: 3px double #9aa5b4; }
}

.workspace-entrance {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
}
.workspace-entrance[popover] {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.workspace-entrance::backdrop { background: transparent; pointer-events: none; }
.workspace-entrance-veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, var(--green-soft), var(--paper) 65%);
}
.workspace-entrance-mascot {
  position: absolute;
  overflow: hidden;
  transform-origin: center;
  will-change: transform, opacity;
}
html[data-theme="1"] .workspace-entrance-mascot,
html[data-theme="2"] .workspace-entrance-mascot {
  filter: invert(1);
}
/* The top layer sits outside the page's inverse theme filter. */
html:is([data-theme="1"], [data-theme="2"]) .workspace-entrance[popover] .workspace-entrance-mascot {
  filter: none;
}
html:is([data-theme="1"], [data-theme="2"]) .workspace-entrance[popover] :is(.workspace-entrance-veil, .workspace-entrance-rule) {
  filter: invert(1);
}
.entrance-poses {
  position: absolute;
  left: 0;
  top: 0;
  width: 1000%;
  height: 600%;
  max-width: none;
  max-height: none;
  display: block;
  transform-origin: top left;
}
@media (prefers-reduced-motion: reduce) {
  .workspace-entrance { display: none; }
}

/* Actions read as annotations on the scrapbook, with a visible keyboard cue. */
html[data-theme="1"] :is(button, a.header-browse-button, a.secondary-button, #start-diagnostic):not(.concept-node, .iso-node, .region-summary, .region-control, .graph-viewcube button) {
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  box-shadow: none;
  color: var(--ink);
  text-decoration: none;
  text-underline-offset: .35em;
  transform: none;
  transition: color .18s ease, border-color .18s ease;
}
html[data-theme="1"] :is(button, a.header-browse-button, a.secondary-button, #start-diagnostic):not(.concept-node, .iso-node, .region-summary, .region-control, .graph-viewcube button):hover:not(:disabled) {
  background: transparent;
  border-bottom-color: var(--green);
  box-shadow: none;
  color: var(--green);
  transform: none;
}
html[data-theme="1"] :is(button, a.header-browse-button, a.secondary-button, #start-diagnostic):not(.concept-node, .iso-node, .region-summary, .region-control, .graph-viewcube button):focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
  border-radius: 3px;
}
html[data-theme="1"] :is(button, a.header-browse-button, a.secondary-button, #start-diagnostic):not(.concept-node, .iso-node, .region-summary, .region-control, .graph-viewcube button):is([aria-pressed="true"], .nav-link.active) {
  background: transparent;
  color: var(--green);
  border-bottom: 1px solid var(--green);
}
html[data-theme="1"] :is(.head-actions, .panel-actions, .graph-zoom-controls) { gap: .35rem .75rem; }
html[data-theme="1"] .head-actions :is(.primary-button, .secondary-button) { padding-inline: .6rem; }
html[data-theme="1"] :is(button, a.header-browse-button, a.secondary-button, #start-diagnostic):not(.concept-node, .iso-node, .region-summary, .region-control, .graph-viewcube button).course-switcher { border-bottom: 1px solid var(--line); }
html[data-theme="1"] :is(button, a.header-browse-button, a.secondary-button, #start-diagnostic):not(.concept-node, .iso-node, .region-summary, .region-control, .graph-viewcube button).context-delete { color: #5bc5ca; }
html[data-theme="1"] :is(button, a.header-browse-button, a.secondary-button, #start-diagnostic):not(.concept-node, .iso-node, .region-summary, .region-control, .graph-viewcube button).context-delete:hover { color: #3cb7bd; }
@media (pointer: coarse) {
  html[data-theme="1"] :is(.header-browse-button, .theme-button, .graph-toolbar button, .graph-zoom-controls button, .graph-interaction-actions button) {
    min-height: 44px;
  }
}

/* A fine illuminated rule is drawn before each section appears. */
.workspace-entrance-rule {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--green), var(--ink), transparent);
  transform-origin: left center;
  pointer-events: none;
}
