/* Looks like the seat chart taped up in the classroom, redrawn on screen.
   Reuses the drawing's own symbols: window-side sliding line, corridor dashes, red TA seats. */

:root {
  color-scheme: light;

  --paper: #ffffff;
  --desk: #fdfdfb;
  --page: #edeeea;
  --ink: #16181d;
  --ink-soft: #5d636d;
  --line: #c7cac4;
  --line-soft: #e2e4df;
  --question: #1d4ed8;
  --check: #c8102e;
  --red: #c8102e; /* The drawing's red, for TA seats and errors */

  --font: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic",
    "Noto Sans JP", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, "Roboto Mono", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
}

.top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px;
  border-bottom: 1.5px solid var(--ink);
  background: var(--paper);
}

.top h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.top .code {
  font-family: var(--mono);
  margin-right: 10px;
}

#infoButton {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  font-style: italic;
  line-height: 1;
  cursor: pointer;
}

#infoButton:hover {
  background: var(--ink);
  color: var(--paper);
}

/* Repository link, pushed to the right end of the header */
.repo {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  color: var(--ink-soft);
  text-decoration: none;
}

.repo:hover {
  color: var(--ink);
}

.repo svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
  padding: 24px;
}

/* The drawing (seat map) */

.plan {
  padding: clamp(12px, 1.4vw, 20px);
  border: 1.5px solid var(--ink);
  background: var(--paper);
}

.plan-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.wall-label {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}

.swatch {
  width: 11px;
  height: 11px;
  margin-left: 10px;
  border: 1px solid var(--line);
}

.swatch.q {
  background: var(--question);
  border-color: var(--question);
}

.swatch.c {
  background: var(--check);
  border-color: var(--check);
}

/* Window-side sliding line */
.window-bar {
  height: 9px;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  background: repeating-linear-gradient(
    90deg,
    transparent 0 48px,
    var(--ink) 48px 50px
  );
}

.map-scroll {
  container-type: inline-size;
  overflow-x: auto;
}

.map {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: clamp(3px, 0.45vw, 8px);
  padding: clamp(8px, 1vw, 14px) 0;
  background-image: linear-gradient(
      to right,
      rgba(22, 24, 29, 0.05) 1px,
      transparent 1px
    ),
    linear-gradient(to bottom, rgba(22, 24, 29, 0.05) 1px, transparent 1px);
  background-size: 22px 22px;
}

.desk {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  aspect-ratio: 5 / 4;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--desk);
}

/* One desk holds two seats; the left one is the earlier CSV row */
.desk .half {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 2px 5px;
  transition: background-color 0.18s ease;
}

/* Time left before a called seat is taken down on its own */
.desk .remain {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: clamp(9px, 1vw, 12px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.desk .half.right {
  border-left: 1px solid var(--line-soft);
}

/* Desk numbers sit on a paper-colored tag so they stay readable on a filled seat */
.desk .name {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1px 5px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: clamp(10px, 1.6vw, 18px);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}

.desk .flags {
  white-space: pre-line;
  line-height: 1.2;
  font-size: clamp(8px, 0.9vw, 11px);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
}

.desk .flags:empty {
  display: none;
}

/* Half the desk is filled while called, so the color reads from across the room */
.desk .half.q {
  background-color: var(--question);
  color: var(--paper);
}

.desk .half.c {
  background-color: var(--check);
  color: var(--paper);
}

.desk .half.q.c {
  background-image: linear-gradient(
    105deg,
    var(--question) 0 50%,
    var(--check) 50% 100%
  );
}

/* Mark your own seat with the hatching used on drawings */
.desk .half.mine {
  box-shadow: inset 0 0 0 2px var(--ink);
  background-image: repeating-linear-gradient(
    45deg,
    rgba(22, 24, 29, 0.07) 0 5px,
    transparent 5px 10px
  );
}

.desk .half.mine.q,
.desk .half.mine.c {
  background-image: none;
}

.desk .half.mine.q.c {
  background-image: linear-gradient(
    105deg,
    var(--question) 0 50%,
    var(--check) 50% 100%
  );
}

/* 10A-10E are TA seats, drawn only to match the room */
.desk.ta-seat {
  border-color: var(--red);
  background: var(--paper);
}

.desk.ta-seat .name {
  color: var(--red);
  letter-spacing: 0.06em;
}

.corridor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1.5px dashed var(--line);
}

.ta {
  padding: 6px 16px;
  border: 1.5px solid var(--red);
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

/* Controls */

.rail {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 24px;
}

.card {
  padding: 18px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
}

.card label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--ink-soft);
}

input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 17px;
  letter-spacing: 0.06em;
}

#idForm button {
  width: 100%;
  margin-top: 10px;
}

button {
  padding: 10px 14px;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

#idForm button:hover {
  background: var(--ink);
  color: var(--paper);
}

.seat-label {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.seat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 2px 0 16px;
  font-family: var(--mono);
  font-size: 46px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.04em;
}

.seat .side {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0;
}

.actions {
  display: grid;
  gap: 8px;
}

.actions .q {
  border-color: var(--question);
  color: var(--question);
}

.actions .q:hover {
  background: var(--question);
  color: var(--paper);
}

.actions .c {
  border-color: var(--check);
  color: var(--check);
}

.actions .c:hover {
  background: var(--check);
  color: var(--paper);
}

.actions .ghost {
  border-color: var(--line);
  color: var(--ink-soft);
}

.actions .ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.status {
  margin: 14px 0 0;
  font-size: 14px;
  font-weight: 700;
}

.status:empty {
  display: none;
}

.link {
  margin-top: 12px;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink-soft);
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:hover {
  color: var(--ink);
}

.err {
  margin: 0;
  color: var(--red);
  font-size: 14px;
  font-weight: 700;
}

.err:empty {
  display: none;
}

:focus-visible {
  outline: 2px solid var(--question);
  outline-offset: 2px;
}

/* Info dialog */

dialog {
  max-width: 480px;
  padding: 22px;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
}

dialog::backdrop {
  background: rgba(22, 24, 29, 0.45);
}

dialog h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

dialog ul {
  margin: 0 0 18px;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .rail {
    position: static;
    order: -1;
  }

  .top {
    padding: 14px 16px;
  }
}

/* Narrow seats cannot fit labels, so color alone carries the state */
@container (max-width: 1100px) {
  .desk .flags {
    display: none;
  }
}

/* Phone-sized maps leave no room for the clock in a seat half either */
@container (max-width: 480px) {
  .desk .remain {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .desk {
    transition: none;
  }
}
