/* ============================================================
   Pitch Diagram Studio — style.css
   Aesthetic: Editorial sports tool. Stark monochrome chrome,
   bold condensed type, vivid pitch as centrepiece.
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:        #0f0f0f;
  --surface:   #1a1a1a;
  --surface2:  #242424;
  --border:    #333;
  --border2:   #444;
  --text:      #f0f0f0;
  --text-muted:#888;
  --accent:    #e8ff3c;       /* sharp lime accent */
  --accent-fg: #0f0f0f;
  --danger:    #ff4d4d;
  --home-fill: #111;
  --home-stroke:#f0f0f0;
  --away-fill: #f0f0f0;
  --away-stroke:#111;
  --radius-btn: 999px;
  --radius-panel: 10px;
  --font-display: 'Barlow Condensed', sans-serif;
  --font-body: 'Barlow', sans-serif;
  --header-h: 56px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  min-height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  z-index: 10;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.1;
  color: var(--text);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1.5px solid transparent;
  border-radius: var(--radius-btn);
  padding: 7px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .12s, color .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
  line-height: 1;
}

.btn:active { opacity: .8; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn-primary:hover { background: #d4f000; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border2);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.btn-icon {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
  padding: 7px 12px;
  font-size: 12px;
  gap: 5px;
}
.btn-icon:hover { border-color: var(--border2); }

/* ── Theme select ──────────────────────────────────────────── */
.theme-select {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--surface2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 7px 14px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.theme-select:hover { border-color: var(--border2); }

/* ── Main layout ───────────────────────────────────────────── */
.app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── Panels ────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border-color: var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-shrink: 0;
  overflow-y: auto;
}

.panel-tools {
  width: 100px;
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  gap: 16px;
}

.panel-settings {
  width: 210px;
  border-left: 1px solid var(--border);
  padding: 12px 12px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 2px 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

/* ── Tool buttons ──────────────────────────────────────────── */
.tool-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tool-btn {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 6px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background .1s, color .1s, border-color .1s;
  width: 100%;
}

.tool-btn:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border2);
}

.tool-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.tool-btn.active svg { stroke: var(--accent-fg); }

.tool-btn-danger {
  color: var(--danger);
  border-color: #3a1a1a;
}
.tool-btn-danger:hover {
  background: #2a0a0a;
  border-color: var(--danger);
}
.tool-btn-danger:disabled {
  color: #555;
  border-color: var(--border);
  cursor: not-allowed;
  background: transparent;
}
.tool-btn-danger:disabled svg { opacity: .4; }

/* ── Pitch wrapper ─────────────────────────────────────────── */
.pitch-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
  position: relative;
  padding: 20px;
}

#pitchCanvas {
  display: block;
  border-radius: 6px;
  /* shadow gives depth without glassmorphism */
  box-shadow: 0 8px 40px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.4);
  max-width: 100%;
  max-height: 100%;
}

/* ── Settings panel content ────────────────────────────────── */
.settings-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 8px;
  text-align: center;
}

.settings-empty p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
  margin-top: 6px;
}

.field-input,
.field-select {
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--surface2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  width: 100%;
  outline: none;
  transition: border-color .1s;
}

.field-input:focus,
.field-select:focus { border-color: var(--accent); }

.field-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

/* ── Rotate controls ───────────────────────────────────────── */
.rotate-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.direction-display {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 0.02em;
  min-width: 40px;
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 20px;
  border-radius: var(--radius-btn);
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.settings-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 4px 2px;
}

/* ── Quick Setup / preset buttons ─────────────────────────── */
.quick-setup {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
  text-align: left;
}

.quick-setup .panel-label {
  display: block;
  margin-bottom: 4px;
}

.preset-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.preset-group-label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: .7;
}

.preset-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.preset-btn {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: var(--surface2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 5px 11px;
  cursor: pointer;
  transition: background .1s, color .1s, border-color .1s;
  white-space: nowrap;
  line-height: 1;
}

.preset-btn:hover {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.preset-btn:active { opacity: .8; }

/* ── About this app (collapsible) ─────────────────────────── */
.about-app {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  color: var(--text-muted);
}

.about-app summary {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.about-app summary::-webkit-details-marker { display: none; }

.about-app summary::after {
  content: "+";
  float: right;
  color: var(--accent);
}

.about-app[open] summary::after { content: "−"; }

.about-app-body {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.6;
}

.about-app-body p { margin-bottom: 8px; }

.about-app-body ul {
  padding-left: 16px;
  margin: 8px 0;
}

.about-app-body li { margin-bottom: 5px; }

/* ── Cursor states (set via JS class on canvas) ────────────── */
#pitchCanvas { cursor: default; }
#pitchCanvas.cursor-crosshair { cursor: crosshair; }
#pitchCanvas.cursor-text { cursor: text; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Responsive — mobile ───────────────────────────────────── */
@media (max-width: 680px) {
  body { overflow: auto; }
  html, body { height: auto; }

  .app-main {
    flex-direction: column;
    overflow: visible;
  }

  /* Allow header-actions to wrap on very narrow screens */
  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }

  .panel-tools {
    width: 100%;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .panel-tools .panel-section {
    flex-direction: row;
    align-items: center;
  }

  .tool-group {
    flex-direction: row;
  }

  .panel-settings {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .settings-content {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
  }

  .panel-wrapper {
    flex: 1 1 140px;
  }

  .pitch-wrapper {
    padding: 12px;
    min-height: 300px;
  }

  .brand-sub { display: none; }

  .btn { padding: 7px 12px; font-size: 12px; }
}
