@font-face {
  font-family: 'Eurostile';
  src: url('/fonts/Eurostile.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Eurostile';
  src: url('/fonts/Eurostile Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Eurostile Extended';
  src: url('/fonts/Eurostile_Extd.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Eurostile Extended';
  src: url('/fonts/Eurostile_Extd_Black.otf') format('opentype');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Eurostile Extended';
  src: url('/fonts/Eurostile_Extd_Black_Italic.otf') format('opentype');
  font-weight: 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --black: #0a0a0a;
  --white: #ffffff;
  --red: #e2001a;
  --grey: #8a8a8a;
  --grey-dark: #1c1c1c;
  --grey-panel: #141414;
  --font-body: 'Eurostile', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: 'Eurostile Extended', 'Eurostile', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--black);
  color: var(--white);
  font-family: var(--font-body);
  min-height: 100vh;
}

.app-header {
  padding: 1.5rem 2rem 1rem;
  border-bottom: 3px solid var(--red);
}

.app-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}

.app-subtitle {
  margin: 0.25rem 0 0;
  color: var(--grey);
}

.local-time-block {
  text-align: right;
}

.local-time-label {
  display: block;
  color: var(--grey);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.local-time-value {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: 1.75rem;
  font-weight: 900;
}

.app-nav {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.app-nav-label {
  color: var(--grey);
  font-size: 0.85rem;
}

.app-nav a {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--grey-dark);
  border-radius: 999px;
}

.app-nav a:hover {
  border-color: var(--red);
}

.display-link-group {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.display-link-sub {
  font-size: 0.8rem;
  color: var(--grey);
  border-color: transparent;
  padding: 0.2rem 0.5rem;
}

.display-link-sub:hover {
  color: var(--white);
}

.app-nav a {
  color: var(--red);
  text-decoration: none;
  font-weight: 600;
}
.app-nav a:hover {
  text-decoration: underline;
}

main {
  padding: 2rem;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
}

.category-card {
  background: var(--grey-panel);
  border: 2px solid var(--grey-dark);
  border-radius: 12px;
  padding: 1.5rem;
  overflow: hidden;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.category-card.state-running {
  border-color: var(--red);
}

.category-card.state-cop_closed {
  border-color: var(--red);
  box-shadow: 0 0 24px rgba(226, 0, 26, 0.35);
}

/* Category brand backgrounds — 5K on white.png, 10K on red.png, the COP
   block included since it lives inside the same card (no separate bg). */
.category-card[data-name="5K"] {
  background: var(--white) url('/img/white.png') center / cover no-repeat;
  color: var(--black);
}

.category-card[data-name="10K"] {
  background: var(--red) url('/img/red.png') center / cover no-repeat;
  color: var(--white);
}

.category-card[data-name="5K"] .clock-label {
  color: #4a4a4a;
}

.category-card[data-name="5K"] .status-badge {
  color: var(--black);
  background: rgba(255, 255, 255, 0.65);
  border-color: var(--black);
}

.category-card[data-name="5K"] .status-badge.status-running {
  color: var(--white);
  background: var(--red);
  border-color: var(--red);
}

.category-card[data-name="5K"] .btn-reset {
  color: var(--black);
  border-color: var(--black);
}
.category-card[data-name="5K"] .btn-reset:hover {
  border-color: var(--red);
  color: var(--red);
}

.cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.cat-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--grey-dark);
  color: var(--grey);
  border: 1px solid var(--grey);
}

.status-badge.status-running {
  color: var(--white);
  background: var(--red);
  border-color: var(--red);
}

.status-badge.status-cop_closed {
  color: var(--red);
  background: var(--black);
  border-color: var(--red);
  animation: pulse 1.2s ease-in-out infinite;
}

.clock-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.clock-block {
  flex: 1;
  min-width: 140px;
}

.clock-label {
  color: var(--grey);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}

.clock-value {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.clock-block.cop .clock-value {
  color: var(--white);
}

.clock-value.cop-warning {
  color: var(--red);
  animation: pulse 1s ease-in-out infinite;
}

.clock-value.cop-closed-loop {
  color: var(--red);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.controls {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.75rem;
}

.btn {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  letter-spacing: 0.03em;
}

.btn-start {
  background: var(--red);
  color: var(--white);
}
.btn-start:disabled {
  background: var(--grey-dark);
  color: var(--grey);
  cursor: not-allowed;
}

.btn-reset {
  background: transparent;
  color: var(--white);
  border-color: var(--grey);
}
.btn-reset:hover {
  border-color: var(--red);
  color: var(--red);
}

.manual-start {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed rgba(138, 138, 138, 0.4);
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.manual-start label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--grey);
  flex: 1;
  min-width: 180px;
}

.manual-start input[type='time'] {
  background: var(--grey-dark);
  border: 1px solid var(--grey);
  color: var(--white);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.95rem;
}

.category-card[data-name='5K'] .manual-start input[type='time'] {
  background: rgba(255, 255, 255, 0.6);
  color: var(--black);
  border-color: var(--black);
}

.btn-manual-start {
  background: transparent;
  color: var(--grey);
  border-color: var(--grey);
  font-size: 0.8rem;
  padding: 0.45rem 0.9rem;
  white-space: nowrap;
}
.btn-manual-start:hover:not(:disabled) {
  border-color: var(--white);
  color: var(--white);
}
.btn-manual-start:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.lower-grid {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--grey-dark);
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 2.5rem;
  align-items: start;
}

.add-category {
  max-width: 420px;
}

.add-category h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.add-category form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.add-category label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--grey);
}

.add-category input {
  background: var(--grey-dark);
  border: 1px solid var(--grey);
  color: var(--white);
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  font-size: 1rem;
}

.btn-add {
  background: var(--white);
  color: var(--black);
  align-self: flex-start;
}

.form-error {
  color: var(--red);
  min-height: 1.2em;
  font-size: 0.9rem;
}

.event-log-section h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.event-log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--grey-dark);
  border-radius: 8px;
}

.event-log:empty::after {
  content: 'Belum ada aktivitas.';
  display: block;
  padding: 1rem;
  color: var(--grey);
  font-size: 0.9rem;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--grey-dark);
  font-size: 0.9rem;
}
.event-row:last-child {
  border-bottom: none;
}

.event-time {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  color: var(--grey);
  min-width: 4.5rem;
}

.event-category {
  font-weight: 700;
  min-width: 3.5rem;
}

.event-type {
  color: var(--grey);
  margin-left: auto;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.event-row.event-start .event-type {
  color: var(--red);
}
.event-row.event-cop_closed .event-type {
  color: var(--red);
  font-weight: 700;
}

/* Public display: bigger, higher contrast, no controls */
body.public-display main {
  padding: 3rem 2rem;
}

.categories-grid-public {
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 2.5rem;
}

.categories-grid-public .category-card {
  padding: 2.5rem;
  border-width: 3px;
  text-align: center;
}

.categories-grid-public .cat-header {
  justify-content: center;
  gap: 1rem;
}

.categories-grid-public .cat-name {
  font-size: 2.5rem;
}

.categories-grid-public .status-badge {
  font-size: 1rem;
  padding: 0.4rem 1rem;
}

.categories-grid-public .clock-row {
  justify-content: center;
}

.categories-grid-public .clock-label {
  font-size: 1.1rem;
}

.categories-grid-public .clock-value {
  font-size: 5rem;
}

/* Single-category screen (?category=10K / ?id=2): full-bleed, fills the
   whole browser viewport instead of floating as a bounded card. This is
   meant to run on a dedicated physical screen (gate/arch/checkpoint), so
   there's no dashboard chrome around it — just the brand background and
   the numbers, edge to edge. */
body.display-single {
  margin: 0;
  overflow: hidden;
}

body.display-single main {
  padding: 0;
}

.categories-grid-single {
  display: block;
  min-height: 100vh;
}

.categories-grid-single .category-card {
  width: 100%;
  min-height: 100vh;
  max-width: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 4vw;
}

/* Stack race clock + COP vertically — side by side they'd overflow their
   flex items and overlap each other (checked at 1920x1080 and 800x600). */
.categories-grid-single .clock-row {
  flex-direction: column;
  align-items: center;
  gap: 4vh;
}

.categories-grid-single .cat-header {
  margin-bottom: 4vh;
}

.categories-grid-single .cat-name {
  font-size: clamp(2.5rem, 6vw, 6rem);
}

.categories-grid-single .status-badge {
  font-size: clamp(1rem, 1.8vw, 1.75rem);
  padding: 0.5rem 1.5rem;
}

.categories-grid-single .clock-label {
  font-size: clamp(1.2rem, 2.2vw, 2.25rem);
}

.categories-grid-single .clock-value {
  font-size: clamp(3.5rem, 11vw, 13rem);
  line-height: 1;
}
