/* entry.css — Presentation of a single color group G/H[n] (tools/make_entry_page.py).
 * Shares Light / Dark / System tokens and sticky topbar from theme.css. */
@import url('theme.css?v=26-12-04-13-22-00');

:root {
  --cell: 235px;
}

/* ---- Entry Header ------------------------------------------------------ */

header.entry {
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  padding: 1rem 0 1rem;
  margin-bottom: 1.4rem;
}
.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem 1.25rem;
}
header.entry h1 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.15;
}
header.entry h1 .sub { color: var(--muted); font-weight: 400; }
header.entry .lede {
  margin: .3rem 0 0;
  color: var(--muted);
  font-size: .92rem;
  max-width: 78ch;
}
header.entry .lede b { color: var(--ink); font-weight: 600; }
.entry-live-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  padding-top: .15rem;
}
.sync-ov-lbl {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .5rem;
  font-size: .8rem;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}
.sync-ov-lbl input { margin: 0; accent-color: var(--accent); }

/* ---- Inline Interactive Live Preview Drawer ---------------------------- */

#live-drawer {
  margin: 0 0 1.4rem;
  background: var(--panel);
  border: 1px solid var(--accent-bd);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.live-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .45rem .8rem;
  padding: .5rem .75rem;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  font-size: .84rem;
}
.live-tabs, .live-proj {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .28rem;
}
.live-tabs .lt-lbl, .live-proj .lt-lbl {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-right: .2rem;
}
.live-acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}
.live-frame-wrap {
  position: relative;
  width: 100%;
  height: 490px;
  background: var(--panel-alt);
  transition: height .18s ease;
}
#live-drawer.tall .live-frame-wrap { height: 74vh; }
#live-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.live-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .4rem 1rem;
  padding: .35rem .75rem;
  background: var(--panel-alt);
  border-top: 1px solid var(--rule);
  font-size: .78rem;
  color: var(--muted);
}

/* ---- Copyable Math Pills & Related Subgroups --------------------------- */

.copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .5rem;
  margin-top: .25rem;
}
.copy-code {
  display: inline-block;
  padding: .12rem .42rem;
  background: var(--panel-alt);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .84rem;
  color: var(--ink);
  word-break: break-all;
}
.copy-btn.copied {
  border-color: var(--ok-ink);
  color: var(--ok-ink);
}
.rel-group {
  margin-top: .35rem;
}
.rel-group + .rel-group { margin-top: .5rem; }
.rel-lbl {
  font-size: .76rem;
  color: var(--muted);
  display: block;
  margin-bottom: .2rem;
}

/* ---- Section Headings -------------------------------------------------- */

h2.sec {
  font-size: .78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  margin: 2.2rem 0 .85rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--line);
}

/* ---- Facts Grid -------------------------------------------------------- */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 0;
}
.fact { background: var(--panel); padding: .75rem .9rem; }
.fact dt {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: .28rem;
}
.fact dt.plain { text-transform: none; letter-spacing: .01em; font-size: .82rem; }
.fact dd { margin: 0; font-size: 1rem; }
.fact dd.small { font-size: .87rem; line-height: 1.5; color: var(--ink-2); }
.fact dd .note { display: block; font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.fact dd ul.gens {
  list-style: none;
  margin: .3rem 0 0;
  padding: 0;
  font-size: .84rem;
  color: var(--muted);
}
.fact dd ul.gens li { margin: .12rem 0; }
.fact dd ul.gens code { color: var(--ink); }
.fact dd .sibs {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .3rem;
}
.name { font-family: var(--mono); font-weight: 600; color: var(--ink); }

/* ---- Color Action Table ------------------------------------------------ */

table.action {
  border-collapse: collapse;
  background: var(--panel);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.action th, table.action td {
  border: 1px solid var(--rule);
  padding: .28rem .45rem;
  text-align: center;
}
table.action th {
  font-weight: 600;
  color: var(--muted);
  font-size: .8rem;
  background: var(--panel-alt);
}
table.action th.gen { font-family: var(--mono); color: var(--ink); font-size: .95rem; }
table.action td.cyc { text-align: left; font-family: var(--mono); color: var(--muted); padding: .28rem .65rem; }

.sw {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  border: 1px solid rgba(128, 128, 128, .55);
  vertical-align: -.22em;
  border-radius: 3px;
}
table.action .sw { cursor: pointer; }

/* ---- Image Stacks ------------------------------------------------------ */

.stack {
  position: relative;
  aspect-ratio: var(--panel-aspect, 1 / 1);
  background: var(--art-bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  cursor: zoom-in;
  transition: border-color .12s;
}
body.bg-checker table.grid .stack,
body.bg-checker #lb-stack { background: var(--art-checker); }
body.bg-dark table.grid .stack,
body.bg-dark #lb-stack { background: var(--art-dark); }

.stack:hover, .stack:focus-visible { border-color: var(--accent); outline: none; }
.stack:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.stack img, .stack .tile { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stack .tile {
  background-repeat: no-repeat;
  background-size: calc(var(--n) * 100%) calc(var(--n) * 100%);
  background-position: calc(var(--tx) * 100% / var(--nm1)) calc(var(--ty) * 100% / var(--nm1));
}
/* Caption text lives inside .cap for lightbox titles and table.grid hover
 * tooltips; never rendered as a static corner badge over the artwork. */
.stack .cap {
  display: none;
}

/* Delayed floating tooltip for N x N partition table thumbnails */
.cell-tip {
  position: fixed;
  z-index: 70;
  pointer-events: none;
  padding: .24rem .55rem;
  border-radius: var(--radius-sm);
  background: rgba(20, 24, 31, .94);
  color: #f4f7fb;
  font-size: .78rem;
  font-weight: 550;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, .14);
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .12s ease, transform .12s ease;
}
.cell-tip.open {
  opacity: 1;
  transform: translateY(0);
}
.cell-tip::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  margin-left: -4px;
  border: 4px solid transparent;
  border-top-color: rgba(20, 24, 31, .94);
}
.cell-tip.below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: rgba(20, 24, 31, .94);
}

/* Overlay layer opacities & visibility toggles */
.stack .ghost { opacity: .3; }
.stack img.gtil { opacity: .15; }
.stack img.htil { opacity: .3; }
.stack img.gfd, .stack img.hfd { opacity: .35; }
.stack img.gsym, .stack img.hsym { opacity: .75; }

.stack img[data-src] { display: none; }

body.off-pat .stack .pat, body.off-ghost .stack .ghost,
body.off-gfd img.gfd, body.off-hfd img.hfd,
body.off-gtil img.gtil, body.off-htil img.htil,
body.off-gsym img.gsym, body.off-hsym img.hsym,
body.off-f img.fglyph, body.off-g img.gglyph { display: none; }

/* ---- Hero Rows --------------------------------------------------------- */

.hero-one, .hero-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.1rem;
}
.hero-one { margin-bottom: 1.25rem; }
.hero-one figure, .hero-row figure { margin: 0; }
.fig-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .35rem .55rem;
  margin-top: .36rem;
}
.hero-one figcaption, .hero-row figcaption {
  font-size: .85rem;
  color: var(--muted);
  margin: 0;
  min-width: 0;
}
.hero-one figcaption b, .hero-row figcaption b { color: var(--ink); font-weight: 600; }
.hero-one figcaption .sub, .hero-row figcaption .sub {
  color: var(--muted);
  margin-left: .28rem;
  font-size: .82rem;
}
.fig-live {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: .22rem;
}

/* ---- Domains Table (G / H x domain, tiling, symmetries) ---------------- */

.geo-wrap, .action-wrap { overflow-x: auto; }
table.geo { border-collapse: collapse; }
table.geo td { padding: .35rem; vertical-align: top; }
table.geo th.row {
  padding: .35rem .7rem;
  font-size: 1.15rem;
  vertical-align: middle;
  color: var(--ink);
}
table.geo th.col {
  font-weight: 600;
  padding: .2rem .35rem;
  text-align: left;
  color: var(--muted);
  font-size: .85rem;
}
table.geo .stack { width: min(255px, 28vw); min-width: 170px; }
table.geo .cellcap {
  font-size: .83rem;
  color: var(--muted);
  margin-top: .32rem;
  max-width: min(255px, 28vw);
}

/* ---- Sticky Layer Toolbar above Partition Table ------------------------ */

.layer-bar {
  position: sticky;
  top: var(--nav-h);
  z-index: 35;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem .8rem;
  margin: 0 0 .75rem;
  padding: .5rem .75rem;
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: .83rem;
}
.layer-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .28rem .55rem;
}
.layer-group + .layer-group {
  padding-left: .7rem;
  border-left: 1px solid var(--rule);
}
.layer-group .lg-lbl {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-right: .1rem;
}
.layer-group label {
  display: inline-flex;
  align-items: center;
  gap: .28rem;
  cursor: pointer;
  color: var(--ink-2);
  white-space: nowrap;
  user-select: none;
}
.layer-group input[type="checkbox"] { margin: 0; accent-color: var(--accent); }
.seg-btn {
  padding: .15rem .48rem;
  font: 500 .78rem/1.3 var(--font-sans);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink-2);
  cursor: pointer;
}
.seg-btn:hover { border-color: var(--accent); color: var(--accent); }
.seg-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ---- Partition Table --------------------------------------------------- */

.cosets {
  overflow: auto;
  max-height: calc(100vh - var(--nav-h) - 5.2rem);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--bg);
  padding: 0 .35rem .35rem 0;
}
table.grid { border-collapse: separate; border-spacing: 0; }
table.grid th, table.grid td { padding: 0; vertical-align: top; }
table.grid td.cell { padding: 3px; }
table.grid td.cell .stack { width: var(--cell); }
table.grid thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--bg);
  box-shadow: inset 0 -1px 0 var(--rule);
}
table.grid thead th.marg { background: var(--marg-bg); }
table.grid thead th:first-child {
  left: 0;
  z-index: 6;
}
table.grid th.corner {
  font-size: .74rem;
  font-weight: 500;
  color: var(--muted);
  padding: .35rem .55rem .35rem .35rem;
  text-align: right;
  vertical-align: bottom;
  white-space: nowrap;
}
table.grid th.col {
  font-size: .85rem;
  font-weight: 600;
  padding: .35rem .2rem .38rem;
  text-align: center;
  color: var(--ink);
  transition: background-color .1s, color .1s;
}
table.grid th.row {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--bg);
  font-size: .84rem;
  font-weight: 600;
  padding: .3rem .65rem .3rem .25rem;
  text-align: right;
  white-space: nowrap;
  color: var(--ink);
  transition: background-color .1s, color .1s;
}
table.grid th .hint { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); }
table.grid .marg { background: var(--marg-bg); }
table.grid td.rep .stack { border-bottom: 4px solid var(--rep-bar); }
table.grid th.col.rep { border-bottom: 4px solid var(--rep-bar); }

table.grid th.hl-row,
table.grid th.hl-col {
  background: var(--accent-bg);
  color: var(--accent);
}
table.grid th.hl-rep {
  background: var(--accent-bg);
  box-shadow: inset 0 0 0 2px var(--rep-bar);
  color: var(--accent);
}

.legend { font-size: .87rem; color: var(--muted); margin: .85rem 0 0; max-width: 96ch; }
.legend b { color: var(--ink); }

/* ---- Lightbox ---------------------------------------------------------- */

#lb {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(12, 15, 22, 0.82);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  gap: .65rem;
}
#lb[hidden] { display: none; }

.lb-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  width: min(88vw, 76vh, 840px);
  color: #f0f6fc;
  font-size: .88rem;
}
.lb-bar-title {
  display: flex;
  align-items: baseline;
  gap: .6rem;
}
#lb-title { font-weight: 650; font-size: 1rem; }
#lb-meta { color: #b4beca; font-size: .82rem; }
.lb-bar-actions {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.lb-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
}
.lb-nav-v {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
}
.lb-arrow {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .1);
  color: #ffffff;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lb-arrow:hover:not(:disabled) { background: rgba(255, 255, 255, .22); border-color: #ffffff; }
.lb-arrow:disabled { opacity: .22; cursor: default; }

#lb-stack {
  width: min(84vw, calc(66vh * var(--panel-aspect-num, 1)), 840px);
  border-color: rgba(255, 255, 255, .3);
  cursor: zoom-out;
  box-shadow: 0 12px 44px rgba(0, 0, 0, .6);
}
#lb-stack .cap { display: none; }

#lb-layers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: .35rem .7rem;
  max-width: min(92vw, 900px);
  padding: .45rem .8rem;
  background: rgba(22, 27, 34, .92);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius-md);
  color: #e6edf3;
  font-size: .8rem;
}
#lb-layers label {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  cursor: pointer;
  white-space: nowrap;
}
#lb-layers input[type="checkbox"] { margin: 0; accent-color: #58a6ff; }
#lb-hint {
  text-align: center;
  color: rgba(240, 246, 252, .75);
  font-size: .78rem;
}

/* ---- Mobile & Touch Adjustments ---------------------------------------- */

@media (max-width: 640px) {
  :root {
    --cell: clamp(115px, 36vw, 155px);
  }
  header.entry {
    padding: .75rem 0;
    margin-bottom: 1rem;
  }
  header.entry h1 {
    font-size: 1.48rem;
  }
  .live-head {
    padding: .42rem .55rem;
    gap: .35rem .5rem;
  }
  .live-tabs {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
  }
  .live-tabs::-webkit-scrollbar { display: none; }
  .live-tabs .lt-lbl { display: none; }
  .live-acts {
    flex: 0 0 auto;
    margin-left: auto;
  }
  #live-drawer .live-acts > :not(#live-close) {
    display: none !important;
  }
  .live-frame-wrap {
    height: min(380px, 52dvh);
  }
  #live-drawer.tall .live-frame-wrap {
    height: 72dvh;
  }
  .hero-one, .hero-row {
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    gap: .85rem;
  }
  .layer-bar {
    position: static;
    gap: .35rem .55rem;
    padding: .45rem .55rem;
    font-size: .79rem;
  }
  .layer-group + .layer-group {
    padding-left: 0;
    border-left: 0;
  }
  .cosets {
    max-height: 74dvh;
  }
  table.grid th.row {
    font-size: .76rem;
    padding: .25rem .45rem .25rem .2rem;
  }
  table.grid th.col {
    font-size: .78rem;
  }
  /* Lightbox mobile: keep all arrows strictly inside viewport bounds */
  #lb {
    padding: .6rem .5rem;
    gap: .45rem;
  }
  .lb-bar {
    width: 100%;
    max-width: 96vw;
    font-size: .82rem;
    gap: .35rem .5rem;
  }
  .lb-stage {
    position: relative;
    width: 100%;
    max-width: 96vw;
    gap: 0;
  }
  .lb-nav-v {
    width: 100%;
    max-width: 100%;
    gap: .35rem;
  }
  #lb-stack {
    width: min(92vw, calc(56dvh * var(--panel-aspect-num, 1)), 540px);
    max-width: 100%;
  }
  #lb-lt, #lb-rt {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    background: rgba(12, 15, 22, 0.72);
    border-color: rgba(255, 255, 255, .38);
  }
  #lb-lt { left: 4px; }
  #lb-rt { right: 4px; }
  #lb-layers {
    max-width: 96vw;
    font-size: .76rem;
    padding: .35rem .55rem;
    gap: .3rem .55rem;
  }
}

@media (pointer: coarse) {
  .seg-btn {
    min-height: 30px;
    padding: .2rem .55rem;
  }
  .lb-arrow {
    width: 2.4rem;
    height: 2.4rem;
    font-size: 1.1rem;
  }
}

/* Phones & tablets (including Galaxy Tab / iPad with wide viewports):
 * keep inline Live preview minimal with only coloring tabs + Close */
:root.is-touch #live-drawer .live-head {
  gap: .35rem .5rem;
}
:root.is-touch #live-drawer .live-tabs {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-width: 100%;
}
:root.is-touch #live-drawer .live-tabs::-webkit-scrollbar { display: none; }
:root.is-touch #live-drawer .live-tabs .lt-lbl { display: none; }
:root.is-touch #live-drawer .live-acts {
  flex: 0 0 auto;
  margin-left: auto;
}
:root.is-touch #live-drawer .live-acts > :not(#live-close) {
  display: none !important;
}
