/* ==========================================================================
   SIAM SIR ICT - FOLDER CARDS (vanilla)
   Flat chapter colour + chapter icon on the back panel, a lightly frosted
   front panel. Light front in the light theme, navy front in the dark theme.
   Behaviour lives in assets/js/glass-folder.js.
   ========================================================================== */

/* ---- section: a dotted desk the folders sit on ---------------------------- */
.gf-desk {
  position: relative;
  isolation: isolate;
}

.gf-desk::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  color: var(--text-main);
  opacity: 0.07;
  background-image: radial-gradient(currentColor 1.1px, transparent 1.4px);
  background-size: 22px 22px;
}

.gf-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 56px 24px;
  align-items: start;
}

.gf-card {
  position: relative;
  min-width: 0;
}

/* an open folder fans above its neighbours */
.gf-card:has(.gf-root[data-open]),
.gf-card:has(.gf-menu[data-open]) {
  z-index: 5;
}

.gf-card .chapter-desc {
  margin-top: 4px;
  max-width: 340px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.chapter-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  max-width: 340px;
  margin-top: 12px;
  font-size: 0.82rem;
  font-weight: 600;
}
.chapter-links a { color: var(--h, var(--primary)); }
.chapter-links a:hover { text-decoration: underline; }
.chapter-links a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
  border-radius: 2px;
}

@media (max-width: 1199px) {
  .gf-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .gf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .gf-grid { grid-template-columns: 1fr; }
}

/* ---- without JavaScript: a plain, readable card ---------------------------- */
.gf:not(.gf-root) {
  padding: 24px;
  border-radius: var(--radius-xl);
  background: var(--bg-card);
}

.gf:not(.gf-root) .gf-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.gf:not(.gf-root) .gf-sheet {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: 0.82rem;
}

.gf:not(.gf-root) .gf-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--h);
}

/* ==========================================================================
   The folder
   ========================================================================== */
.gf-root {
  --gf-px: 0;
  --gf-py: 0;
  --gf-ease: cubic-bezier(.2, .8, .2, 1);
  --gf-spring: cubic-bezier(.34, 1.36, .5, 1);
  --gf-hinge: 0deg;
  --gf-lift: 42px;
  --gf-spread: 0px;
  --gf-fan: 0deg;
  --gf-stack: 15px;
  --gf-ink: #0b1533;
  --gf-ink-soft: rgba(11, 21, 51, .58);
  --gf-focus: var(--primary, #4c8dff);
  position: relative;
  display: block;
  vertical-align: top;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  isolation: isolate;
}
[data-theme="dark"] .gf-root { --gf-ink: #f5f5f7; --gf-ink-soft: rgba(245, 245, 247, .62); }
.gf-root:hover, .gf-root:focus-within { --gf-hinge: -11deg; --gf-lift: -34px; --gf-spread: 8px; --gf-fan: 1.4deg; --gf-stack: 10px; }
.gf-root[data-open] { --gf-hinge: -22deg; --gf-lift: -70px; --gf-spread: 36px; --gf-fan: 4deg; --gf-stack: 22px; }

.gf-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 340px;
  height: 272px;
  transform-origin: 0 0;
}
.gf-tilt {
  position: absolute;
  inset: 0;
  transform: perspective(1400px) rotateX(calc(var(--gf-py) * -3deg)) rotateY(calc(var(--gf-px) * 4deg));
  transition: transform .9s var(--gf-ease);
}

.gf-shadow {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: -6px;
  height: 60px;
  border-radius: 40px;
  background: rgba(16, 18, 24, .34);
  filter: blur(22px);
  transform: translateX(calc(var(--gf-px) * -8px));
  transition: transform .9s var(--gf-ease), opacity .9s var(--gf-ease);
}
[data-theme="dark"] .gf-shadow { background: rgba(0, 0, 0, .62); }

.gf-back {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--h, #2448d8);
  color: var(--bg-card);
}
.gf-back .gf-icon {
  position: absolute;
  left: 240px;
  top: 16px;
  width: 38px;
  height: 38px;
  transform: translate(calc(var(--gf-px) * -3px), calc(var(--gf-py) * -2px));
  transition: transform 1.1s var(--gf-ease);
}
.gf-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.gf-rim {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  overflow: visible;
  pointer-events: none;
  fill: none;
}
.gf-back-rim { width: 340px; height: 272px; }
.gf-back-rim path { stroke: rgba(255, 255, 255, .25); stroke-width: 1; }

/* ---- files ------------------------------------------------------------------ */
.gf-root .gf-files {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  /* nothing hangs out of the bottom of the pocket, however tall the stack */
  clip-path: inset(-400px -400px 10px -400px);
}
.gf-sheet-slot { display: contents; }
.gf-sheet-slot[hidden] { display: none; }
.gf-root .gf-sheet {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  left: 34px;
  top: 96px;
  width: 272px;
  height: 184px;
  border-radius: 16px;
  overflow: hidden;
  cursor: default;
  pointer-events: auto;
  background: linear-gradient(180deg, #ffffff 0%, #f2f2f0 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .9),
    0 0 0 .5px rgba(0, 0, 0, .1),
    0 10px 26px -8px rgba(10, 12, 20, .28);
  transform-origin: 50% 100%;
  transform:
    translate(calc(var(--gf-jx) + var(--gf-slot) * var(--gf-spread)), calc(var(--gf-lift) + var(--gf-depth) * var(--gf-stack) * -1))
    rotate(calc(var(--gf-jr) + var(--gf-slot) * var(--gf-fan)));
  transition:
    transform .75s var(--gf-spring) calc(var(--gf-depth) * 40ms),
    box-shadow .4s var(--gf-ease),
    translate .9s var(--gf-ease),
    opacity .9s var(--gf-ease);
}
.gf-root a.gf-sheet,
.gf-root button.gf-sheet { cursor: pointer; }
[data-theme="dark"] .gf-root .gf-sheet {
  background: linear-gradient(180deg, #1f2c55 0%, #131d3d 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 0 0 .5px rgba(255, 255, 255, .08), 0 12px 28px -8px rgba(0, 0, 0, .7);
}
.gf-root .gf-sheet--art,
[data-theme="dark"] .gf-root .gf-sheet--art { background: var(--h, #2448d8); }
.gf-root[data-open] a.gf-sheet:hover,
.gf-root[data-open] a.gf-sheet:focus-visible,
.gf-root[data-open] button.gf-sheet:hover,
.gf-root[data-open] button.gf-sheet:focus-visible {
  transform:
    translate(calc(var(--gf-jx) + var(--gf-slot) * var(--gf-spread)), calc(var(--gf-lift) + var(--gf-depth) * var(--gf-stack) * -1 - 18px))
    rotate(calc(var(--gf-slot) * var(--gf-fan) * .6));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 0 0 .5px rgba(0, 0, 0, .1), 0 22px 40px -12px rgba(10, 12, 20, .42);
  transition-delay: 0s;
}
.gf-root .gf-sheet:focus-visible { outline: 2px solid var(--gf-focus); outline-offset: 2px; }
.gf-root .gf-sheet-head {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 11px;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  white-space: nowrap;
}
.gf-root .gf-sheet-name {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  color: #0b1533;
}
.gf-root .gf-sheet-meta {
  flex: none;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .02em;
  color: rgba(11, 21, 51, .5);
}
[data-theme="dark"] .gf-root .gf-sheet-name { color: #fafafa; }
[data-theme="dark"] .gf-root .gf-sheet-meta { color: rgba(250, 250, 250, .66); }
.gf-root .gf-sheet--art .gf-sheet-name,
[data-theme="dark"] .gf-root .gf-sheet--art .gf-sheet-name { color: var(--bg-card); }
.gf-sheet-icon {
  position: absolute;
  right: 18px;
  bottom: 16px;
  width: 64px;
  height: 64px;
  color: var(--bg-card);
  opacity: .4;
}
.gf-lines {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 40px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.gf-lines i {
  display: block;
  height: 5px;
  border-radius: 3px;
  background: rgba(11, 21, 51, .08);
}
.gf-lines i:first-child { height: 9px; margin-bottom: 4px; background: color-mix(in srgb, var(--h, #2448d8) 35%, transparent); }
[data-theme="dark"] .gf-lines i { background: rgba(255, 255, 255, .08); }
[data-theme="dark"] .gf-lines i:first-child { background: color-mix(in srgb, var(--h, #7c97ff) 45%, transparent); }

.gf-sheet--drop { animation: gf-drop .85s var(--gf-ease) both; }
@keyframes gf-drop {
  0% { translate: 0 -190px; rotate: -9deg; opacity: 0; }
  35% { opacity: 1; }
  72% { translate: 0 10px; rotate: 1deg; }
  100% { translate: 0 0; rotate: 0deg; opacity: 1; }
}

/* ---- front glass -------------------------------------------------------------- */
.gf-front {
  position: absolute;
  left: 0;
  top: 74px;
  width: 340px;
  height: 198px;
  z-index: 10;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transform-origin: 50% 100%;
  transform: perspective(760px) rotateX(var(--gf-hinge));
  transition: transform .8s var(--gf-spring), translate 1s var(--gf-ease), opacity 1s var(--gf-ease);
}
.gf-front--bump { animation: gf-bump .7s var(--gf-ease) .38s both; }
@keyframes gf-bump {
  0% { scale: 1; }
  35% { scale: 1.018 .975; }
  70% { scale: .996 1.006; }
  100% { scale: 1; }
}
.gf-tint {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .93);
}
[data-theme="dark"] .gf-tint {
  background: rgba(17, 27, 59, .94);
}
.gf-front-rim { width: 340px; height: 198px; }
.gf-front-rim path { stroke: var(--h, #2448d8); stroke-opacity: .6; stroke-width: 2; transition: stroke-width .3s var(--gf-ease), stroke-opacity .3s var(--gf-ease); }
.gf-root:hover .gf-front-rim path, .gf-root[data-open] .gf-front-rim path { stroke-opacity: 1; }

.gf-hit {
  all: unset;
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: pointer;
}
.gf-hit:focus-visible ~ .gf-label .gf-title { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.gf-front:has(.gf-hit:focus-visible) .gf-front-rim path { stroke-width: 5; }

.gf-root .gf-label {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 216px;
  pointer-events: none;
  color: var(--gf-ink);
}
.gf-root[data-place="bottom-left"] .gf-label { left: 28px; bottom: 30px; }
.gf-root[data-place="top-left"] .gf-label { left: 28px; top: 34px; }
.gf-root[data-place="top-right"] .gf-label { right: 32px; top: 52px; align-items: flex-start; }
.gf-root .gf-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -.01em;
  color: var(--gf-ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gf-root .gf-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--h, var(--gf-ink-soft));
  white-space: nowrap;
}
.gf-meta--roll { animation: gf-roll .5s var(--gf-ease) both; }
@keyframes gf-roll {
  from { opacity: 0; translate: 0 7px; filter: blur(3px); }
  to { opacity: 1; translate: 0 0; filter: blur(0); }
}

/* ---- the key: + or ··· ---------------------------------------------------------- */
.gf-key {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 12;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .35s var(--gf-spring), box-shadow .35s var(--gf-ease), background .35s var(--gf-ease), opacity .6s var(--gf-ease) .7s, scale .7s var(--gf-spring) .7s;
}
.gf-key:hover { transform: translateY(-2px); }
.gf-key:active { transform: translateY(0) scale(.93); transition-duration: .12s; }
.gf-key:focus-visible { outline: 2px solid var(--gf-focus); outline-offset: 3px; }
.gf-key--add {
  color: #fff;
  background: radial-gradient(120% 90% at 50% 0%, #3a3a3f 0%, #121214 55%, #050506 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .22),
    inset 0 -3px 8px rgba(0, 0, 0, .7),
    0 0 0 1px rgba(0, 0, 0, .75),
    0 14px 22px -8px rgba(0, 0, 0, .55),
    0 3px 6px -2px rgba(0, 0, 0, .35);
}
[data-theme="dark"] .gf-key--add {
  color: #111113;
  background: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, #ececee 55%, #d2d2d6 100%);
  box-shadow: inset 0 1px 0 #fff, inset 0 -3px 8px rgba(0, 0, 0, .14), 0 0 0 1px rgba(0, 0, 0, .4), 0 14px 22px -8px rgba(0, 0, 0, .7);
}
.gf-key--more {
  color: var(--text-main, #0b1533);
  background: var(--bg-elevated, #eef1f7);
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .35);
}
.gf-key--more:hover { color: var(--h, #2448d8); }
.gf-key--more[aria-expanded="true"] { transform: scale(.96); }
.gf-glyph { display: block; max-width: none; fill: none; stroke: currentColor; stroke-linecap: round; }
.gf-glyph--plus { width: 26px; height: 26px; stroke-width: 1.6; }
.gf-glyph--turn { animation: gf-turn .6s var(--gf-spring); }
.gf-glyph--more { width: 30px; height: 12px; stroke-width: 1.7; }
@keyframes gf-turn { from { rotate: -90deg; } to { rotate: 0deg; } }

/* ---- menu ------------------------------------------------------------------------- */
.gf-menu {
  position: absolute;
  right: 22px;
  bottom: 90px;
  z-index: 20;
  min-width: 190px;
  padding: 6px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #fff);
  box-shadow: 0 0 0 1px var(--border-color, rgba(0, 0, 0, .1)), 0 24px 48px -16px rgba(10, 12, 20, .4);
  transform-origin: 100% 100%;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px) scale(.94);
  transition: opacity .2s var(--gf-ease), transform .32s var(--gf-spring), visibility 0s .32s;
}
.gf-menu[data-open] { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
[data-theme="dark"] .gf-menu {
  box-shadow: 0 0 0 1px var(--border-color), 0 24px 48px -16px rgba(0, 0, 0, .8);
}
.gf-menu-item {
  all: unset;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: #0b1533;
  cursor: pointer;
}
[data-theme="dark"] .gf-menu-item { color: #f4f4f5; }
.gf-menu-item:hover, .gf-menu-item:focus-visible { background: rgba(11, 21, 51, .07); }
[data-theme="dark"] .gf-menu-item:hover, [data-theme="dark"] .gf-menu-item:focus-visible { background: rgba(255, 255, 255, .09); }
.gf-menu-item:focus-visible { outline: 2px solid var(--gf-focus); outline-offset: -2px; }

/* ---- entrance: the folder assembles itself ---------------------------------------- */
.gf-root:not([data-entered]) .gf-back,
.gf-root:not([data-entered]) .gf-back-rim { translate: 0 22px; opacity: 0; }
.gf-root:not([data-entered]) .gf-sheet { translate: 0 -120px; opacity: 0; }
.gf-root:not([data-entered]) .gf-front { translate: 0 46px; opacity: 0; }
.gf-root:not([data-entered]) .gf-key { opacity: 0; scale: .6; }
.gf-root:not([data-entered]) .gf-shadow { opacity: 0; }
.gf-back, .gf-back-rim { transition: translate 1s var(--gf-ease), opacity .9s var(--gf-ease); }
.gf-root[data-entered] .gf-sheet { transition-delay: calc(var(--gf-depth) * 40ms), 0s, calc(.18s + var(--gf-depth) * 90ms), calc(.18s + var(--gf-depth) * 90ms); }
.gf-root[data-entered] .gf-front { transition-delay: 0s, .42s, .42s; }

@media (prefers-reduced-motion: reduce) {
  .gf-root *, .gf-root *::before, .gf-root *::after {
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    animation: none !important;
  }
  .gf-tilt { transform: none; }
}
