/* Timezone Overlap — hyper-minimal brutalism */

:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --rule: #111111;
  --overlap: #84cc16;
  --working: #cccccc;
  --font: "IBM Plex Mono", ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;
  --max-width: 960px;
  --row-label-width: 11rem;
  --time-width: 5.5rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
}

a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover,
a:focus-visible {
  text-decoration-thickness: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header */

.site-header {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.25rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.site-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.site-tagline {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  max-width: 36rem;
}

/* Main layout */

.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.panel {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
}

.controls-grid {
  position: relative;
  z-index: 5;
  overflow: visible;
  border-bottom: 1px solid var(--rule);
}

.controls-grid .panel {
  border-bottom: none;
}

@media (min-width: 641px) {
  .controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
  }

  .controls-grid .panel-add {
    padding-right: 1.5rem;
    border-right: 1px solid var(--rule);
  }
}

.panel-label {
  margin: 0 0 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Search */

.search-wrap {
  position: relative;
  z-index: 20;
}

.search-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.625rem;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 0;
  outline: none;
}

.search-input:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 1px;
}

.search-results {
  position: absolute;
  z-index: 30;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 18rem;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-top: none;
}

.search-results li {
  padding: 0.5rem 0.625rem;
  font-size: 0.8125rem;
  cursor: pointer;
  border-bottom: 1px solid var(--rule);
}

.search-results li:last-child {
  border-bottom: none;
}

.search-results li:hover,
.search-results li:focus,
.search-results li[aria-selected="true"] {
  background: var(--fg);
  color: var(--bg);
  outline: none;
}

.search-results .result-tz {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted);
}

.search-results li:hover .result-tz,
.search-results li:focus .result-tz,
.search-results li[aria-selected="true"] .result-tz {
  color: #cccccc;
}

/* IANA fallback */

.iana-fallback {
  margin-top: 1rem;
}

.iana-summary {
  font-size: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.iana-select {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.5rem 0.625rem;
  font-family: var(--font);
  font-size: 0.8125rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 0;
}

.iana-select:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 1px;
}

/* Buttons */

.btn {
  margin-top: 0.5rem;
  padding: 0.375rem 0.75rem;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 0;
  cursor: pointer;
}

.btn:hover:not(:disabled),
.btn:focus-visible:not(:disabled) {
  background: var(--fg);
  color: var(--bg);
  outline: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-remove {
  padding: 0.125rem 0.375rem;
  font-size: 0.6875rem;
}

/* Hours controls */

.hours-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
}

.hours-fieldset {
  margin: 0;
  padding: 0;
  border: none;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.375rem 0.75rem;
  align-items: center;
}

.hours-legend {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.hours-fieldset label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hours-fieldset input[type="time"] {
  padding: 0.25rem 0.375rem;
  font-family: var(--font);
  font-size: 0.8125rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 0;
}

.hours-fieldset input[type="time"]:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 1px;
}

/* Overlap readout */

.overlap-readout {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.6;
}

/* Timeline */

.axis-label {
  margin: 0 0 1rem;
  font-size: 0.6875rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.timeline-container {
  position: relative;
}

.timeline-axis {
  display: grid;
  grid-template-columns: var(--row-label-width) var(--time-width) 1fr;
  margin-bottom: 0.25rem;
}

.timeline-axis-labels {
  grid-column: 3;
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  font-size: 0.5625rem;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.25rem;
}

.axis-hour {
  text-align: center;
}

.axis-hour-mark {
  font-weight: 500;
  color: var(--fg);
}

.location-rows {
  display: flex;
  flex-direction: column;
}

.location-row {
  display: grid;
  grid-template-columns: var(--row-label-width) var(--time-width) 1fr;
  align-items: stretch;
  padding: 0.75rem 0;
}

.location-info {
  padding-right: 0.75rem;
  min-width: 0;
}

.location-name {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-tz {
  margin: 0.125rem 0 0;
  font-size: 0.625rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-actions {
  margin-top: 0.375rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.location-current-time {
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding-right: 0.5rem;
  align-self: center;
}

.location-strip-wrap {
  position: relative;
  align-self: center;
  cursor: crosshair;
}

.location-strip {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  height: 1.5rem;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
}

.strip-cell {
  min-width: 0;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.strip-cell.state-asleep {
  background: var(--bg);
}

.strip-cell.state-awake {
  background: repeating-linear-gradient(
    -45deg,
    var(--bg),
    var(--bg) 2px,
    #cccccc 2px,
    #cccccc 3px
  );
}

.strip-cell.state-working {
  background: var(--working);
}

.strip-cell.in-overlap {
  background: var(--overlap);
}

.now-marker {
  position: absolute;
  top: -0.25rem;
  bottom: -0.25rem;
  width: 2px;
  background: var(--fg);
  z-index: 2;
  pointer-events: none;
}

.now-marker::before {
  content: "NOW";
  position: absolute;
  top: -1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.hover-marker {
  position: absolute;
  width: 0;
  border-left: 1px dashed var(--fg);
  z-index: 3;
  pointer-events: none;
}

.hover-marker[hidden],
.hover-readout[hidden] {
  display: none;
}

.hover-readout {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  transform: translate(-50%, -100%);
  min-width: 8rem;
  max-width: 16rem;
  padding: 0.375rem 0.5rem;
  font-size: 0.625rem;
  line-height: 1.45;
  background: var(--bg);
  border: 1px solid var(--rule);
}

.hover-readout.is-overlap {
  border-color: var(--overlap);
}

.hover-readout-axis {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.hover-overlap-badge {
  color: var(--overlap);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hover-readout-locations {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.hover-readout-locations li + li {
  margin-top: 0.125rem;
}

.empty-state {
  margin: 1rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.empty-state[hidden] {
  display: none;
}

/* Legend */

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-top: 1.25rem;
  font-size: 0.6875rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.legend-swatch {
  display: inline-block;
  width: 1rem;
  height: 0.75rem;
  border: 1px solid var(--rule);
}

.legend-asleep {
  background: var(--bg);
}

.legend-awake {
  background: repeating-linear-gradient(
    -45deg,
    var(--bg),
    var(--bg) 2px,
    #cccccc 2px,
    #cccccc 3px
  );
}

.legend-working {
  background: var(--working);
}

.legend-overlap {
  background: var(--overlap);
}

/* Footer */

.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.75rem;
}

.footer-label {
  margin: 0 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.footer-story {
  margin: 0 0 0.75rem;
  max-width: 40rem;
  line-height: 1.6;
  color: var(--muted);
}

.footer-story em {
  font-style: normal;
  font-weight: 500;
  color: var(--fg);
}

.footer-story code {
  font-family: var(--font);
  font-size: 0.6875rem;
}

.footer-credits {
  margin: 1.25rem 0 0;
}

.footer-sep {
  margin: 0 0.5rem;
  color: var(--muted);
}

/* Mobile */

@media (max-width: 640px) {
  :root {
    --row-label-width: 1fr;
    --time-width: 4.5rem;
  }

  .timeline-axis {
    display: none;
  }

  .location-row {
    grid-template-columns: 1fr var(--time-width);
    grid-template-rows: auto auto;
    gap: 0.25rem 0;
  }

  .location-info {
    grid-column: 1 / -1;
  }

  .location-current-time {
    grid-column: 2;
    grid-row: 2;
    text-align: right;
    align-self: end;
    padding-bottom: 0.25rem;
  }

  .location-strip-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
    padding-right: var(--time-width);
  }

  .axis-hour:nth-child(even) {
    visibility: hidden;
  }
}