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

:root {
  --tile-w:   64px;
  --tile-h:   76px;
  --tile-gap:  4px;
  --radius: 4px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* Category fill colors — matched from original ptohe.com PNG */
  --c-race:               #983838;   /* border only; H tile stays white */
  --c-gender:             #A74F52;
  --c-sexual-orientation: #E6995F;
  --c-ethnicity:          #F9E37E;
  --c-age:                #9284B7;
  --c-class:              #746384;
  --c-ability:            #59794C;
  --c-belief-system:      #484F72;
  --c-academic-status:    #E696C8;

  /* How many tiles tall each column is */
  --col-rows: 5;

  --bg:      #e8eaed;
  --surface: #ffffff;
  --border:  rgba(0,0,0,0.10);
  --text:    #1a1a2e;
  --text-dim:#6b6b8a;
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 32px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tagline {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 3px;
  font-style: italic;
}

/* ── Add button ───────────────────────────────────────────────── */
.add-btn {
  background: #e63946;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.15s;
  white-space: nowrap;
}
.add-btn:hover { background: #c0303d; }

/* ── Legend / filter toolbar ──────────────────────────────────── */
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: 1400px;
  margin: 18px auto 10px;
  padding: 0 32px;
}
.legend-item {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 11px;
  border-radius: 20px;
  border: none;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s, box-shadow 0.2s, transform 0.1s;
  opacity: 0.55;
}
.legend-item.is-active {
  opacity: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transform: scale(1.06);
}
.legend-item:hover { opacity: 0.85; }
.legend-item.is-active:hover { opacity: 1; }
.legend-item.all-btn { background: #3d3d3d; }

/* ── Table card ───────────────────────────────────────────────── */
.pt-table {
  display: flex;
  align-items: flex-start;
  gap: var(--tile-gap);        /* same gap between the two tile containers */
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.09);
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto 24px;
  overflow-x: auto;
}

/* ── Tile grid — column-first flex containers ─────────────────── */
.tiles {
  display: flex;
  flex-direction: column;   /* tiles flow top → bottom first … */
  flex-wrap: wrap;          /* … then start a new column        */
  align-content: flex-start;
  gap: var(--tile-gap);
  flex-shrink: 0;
  /* Fixed height (not max-height) — required for Safari flex-column-wrap to work correctly */
  height: calc(var(--col-rows) * var(--tile-h) + (var(--col-rows) - 1) * var(--tile-gap));
}

/* All columns after column 1 are offset down by one row —
   padding-top in a flex column container shifts EVERY column
   down by the same amount, leaving row 1 empty throughout */
.tiles-rest {
  padding-top: calc(var(--tile-h) + var(--tile-gap));
}

/* ── Individual tiles ─────────────────────────────────────────── */
.tile {
  width: var(--tile-w);
  height: var(--tile-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  border-radius: var(--radius);
  cursor: default;
  overflow: hidden;
  user-select: none;
  color: #2a1818;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.25s, filter 0.25s;
}
.tile:hover {
  transform: translateY(-3px) scale(1.08);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2), 0 8px 18px rgba(0,0,0,0.18);
  z-index: 10;
}
.tile-num {
  position: absolute;
  top: 5px; left: 6px;
  font-size: 0.55rem;
  opacity: 0.55;
}
.tile-sym {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}
.tile-name {
  font-size: 0.55rem;
  text-align: center;
  padding: 0 3px;
  margin-top: 4px;
  line-height: 1.2;
  opacity: 0.88;
}

/* ── Filter states ────────────────────────────────────────────── */
.pt-table.is-filtered .tile {
  opacity: 0.12;
  filter: saturate(0.2) brightness(1.4);
}
.pt-table.is-filtered .tile.is-highlighted {
  opacity: 1;
  filter: none;
}
.pt-table.is-filtered .tile.is-highlighted:hover {
  transform: translateY(-3px) scale(1.08);
}
.pt-table.is-filtered .tile:not(.is-highlighted):hover {
  transform: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}

/* ── Per-category tile fills ──────────────────────────────────── */

/* Race: white tile with coloured border */
.tile.race {
  background: #ffffff;
  box-shadow: inset 0 0 0 2px var(--c-race);
  color: #2a1818;
}
.tile.race:hover {
  box-shadow: inset 0 0 0 2px var(--c-race), 0 8px 18px rgba(0,0,0,0.18);
}

.tile.gender             { background: var(--c-gender); }
.tile.sexual-orientation { background: var(--c-sexual-orientation); }
.tile.ethnicity          { background: var(--c-ethnicity); }
.tile.age                { background: var(--c-age); }
.tile.cat-class          { background: var(--c-class); }
.tile.ability            { background: var(--c-ability); }
.tile.belief-system      { background: var(--c-belief-system); }
.tile.academic-status    { background: var(--c-academic-status); }

/* White text on the two darkest fills */
.tile.belief-system,
.tile.cat-class { color: #f0eeff; }

/* ── Legend pill colours ──────────────────────────────────────── */
.legend-item.race               { background: var(--c-race); }
.legend-item.gender             { background: var(--c-gender); }
.legend-item.sexual-orientation { background: var(--c-sexual-orientation); }
.legend-item.ethnicity          { background: var(--c-ethnicity); color: #2a1818; }
.legend-item.age                { background: var(--c-age); }
.legend-item.cat-class          { background: var(--c-class); }
.legend-item.ability            { background: var(--c-ability); }
.legend-item.belief-system      { background: var(--c-belief-system); }
.legend-item.academic-status    { background: var(--c-academic-status); color: #2a1818; }

/* ── Element count ────────────────────────────────────────────── */
.element-count {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 32px;
}

/* ── Modal ────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
.modal-box {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  color: var(--text);
}
.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-box h2 { font-size: 1.2rem; margin-bottom: 6px; }
.modal-intro  { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 20px; }

/* Form fields */
#add-form label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 14px 0 5px;
}
#add-form label .optional { font-weight: 400; text-transform: none; }
#add-form input,
#add-form select,
#add-form textarea {
  width: 100%;
  background: #f7f7fb;
  border: 1px solid #d0d0e0;
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#add-form input:focus,
#add-form select:focus,
#add-form textarea:focus {
  border-color: #e63946;
  box-shadow: 0 0 0 3px rgba(230,57,70,0.12);
}
#add-form textarea { resize: vertical; }

.symbol-wrap { display: flex; align-items: center; gap: 10px; }
.symbol-wrap input { flex: 1; }
.symbol-status { font-size: 0.8rem; white-space: nowrap; min-width: 80px; }
.symbol-status.ok       { color: #1a7a3a; }
.symbol-status.taken    { color: #c0303d; }
.symbol-status.checking { color: var(--text-dim); }

.field-hint { font-size: 0.72rem; color: var(--text-dim); margin-top: 4px; }

.form-error {
  background: #fef0f0;
  border: 1px solid #f5c6c6;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #c0303d;
  margin-top: 14px;
}
.form-success { text-align: center; padding: 12px 0; }
.form-success p { margin-bottom: 16px; font-size: 1rem; color: var(--text); }

.submit-btn {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: #e63946;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.submit-btn:hover:not(:disabled) { background: #c0303d; }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* –– Sidebar ––––––––––––––––––––––––––––––––––––––––––––––––––––*/
#sidebar {
  max-width: 760px;
  margin: 0 auto 32px;
  padding: 0 32px;
  color: #0c0c0c;
  font: 0.9em/1.5em Arial, Helvetica, Geneva, sans-serif;
}

#sidebar p {
  padding: 0;
  margin-top: 0.6em;
}

#sidebar h2 {
  font-weight: bold;
  font-size: 1.3em;
  font-variant: small-caps;
}

/* ── Footer ───────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 22px;
  font-size: 0.76rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
footer a { color: var(--text-dim); }
footer a:hover { color: var(--text); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --tile-w: 56px; --tile-h: 68px; }
  .pt-table { padding: 16px; gap: 14px; }
}
@media (max-width: 600px) {
  :root { --tile-w: 48px; --tile-h: 58px; }
  .site-header, .legend { padding-left: 12px; padding-right: 12px; }
  .tile-sym { font-size: 1.2rem; }
  h1 { font-size: 1rem; }
}
