/* Base styling. Deliberately small: the editor in milestone 4 brings its own sheet. */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --line: #262b35;
  --text: #e7e9ee;
  --muted: #98a0b0;
  --accent: #4c8dff;
  --error: #ff6b6b;
  --ok: #3ecf8e;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

body.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topnav { display: flex; gap: 16px; }
.topnav a { text-decoration: none; color: var(--muted); }
.topnav a:hover { color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-email { color: var(--muted); font-size: 13px; }
.inline-form { display: inline; }

.page { max-width: 960px; margin: 0 auto; padding: 32px 20px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 380px;
}

.auth-card h1 { margin: 0 0 4px; }

h1 { font-size: 22px; letter-spacing: -0.01em; }
.muted { color: var(--muted); }

label {
  display: block;
  margin: 16px 0 6px;
  font-size: 13px;
  color: var(--muted);
}

input, select {
  width: 100%;
  padding: 10px 12px;
  background: #0d1017;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}

select { width: auto; padding: 6px 8px; }

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  font: inherit;
  border: 1px solid var(--line);
  background: #202634;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  margin-top: 20px;
  background: var(--accent);
  border-color: var(--accent);
  color: #08101f;
  font-weight: 600;
}

.btn-quiet { padding: 6px 10px; font-size: 13px; }

.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  padding: 4px 6px;
}
.btn-link.is-active { color: var(--text); font-weight: 600; }

.locale-switch { margin-top: 18px; text-align: center; }

.error, .notice {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.error  { background: rgba(255, 107, 107, 0.12); color: var(--error); }
.notice { background: rgba(76, 141, 255, 0.12); color: var(--accent); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 24px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

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

/* ---------------------------------------------------------------- milestone 2 */

.page-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}
.page-head h1 { margin: 0; flex: 1; }
.page-head h1 a { color: inherit; text-decoration: none; }
.head-actions { display: flex; gap: 8px; align-items: center; }

.btn-inline { width: auto; margin: 0; padding: 8px 12px; font-size: 14px; text-decoration: none; display: inline-block; }
.btn-danger { background: rgba(255, 107, 107, 0.15); border-color: rgba(255, 107, 107, 0.4); color: var(--error); }

.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

.form-narrow { max-width: 460px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 24px 0;
}
.panel h2 { font-size: 16px; margin: 0 0 8px; }
.panel-danger { border-color: rgba(255, 107, 107, 0.3); }

.cards { list-style: none; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
}
.card-item h2 { font-size: 16px; margin: 10px 0 2px; }
.card-item h2 a { color: var(--text); text-decoration: none; }
.card-actions { margin: 12px 0 0; font-size: 14px; }

.swatches { position: absolute; top: 14px; right: 14px; display: flex; gap: 4px; }
.swatches span { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); }

.logo-preview { max-height: 40px; max-width: 160px; object-fit: contain; display: block; margin: 6px 0; }
.logo-preview.on-light { background: #fff; padding: 6px; border-radius: 6px; }
.logo-preview.on-dark { background: #000; padding: 6px; border-radius: 6px; }

.colour-row { display: flex; gap: 24px; }
.colour-row input[type="color"] { width: 56px; height: 36px; padding: 2px; }

.search-row { display: flex; gap: 10px; align-items: center; margin: 20px 0; }
.search-row input { max-width: 320px; }

.grid { list-style: none; padding: 0; display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tile { display: flex; flex-direction: column; gap: 6px; }
.tile-link { text-decoration: none; color: var(--text); display: block; }
.tile-title { display: block; font-size: 14px; line-height: 1.35; margin-top: 8px; }

.thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0d1017;
}
.thumb-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin: 0;
}

.badges { display: flex; gap: 4px; }
.badge {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 5px;
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.badge-on { background: var(--accent); border-color: var(--accent); color: #08101f; font-weight: 700; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 28px 0; }

.post-detail { display: grid; grid-template-columns: 280px 1fr; gap: 24px; margin: 24px 0; align-items: start; }
.post-media img { width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.post-text h2 { font-size: 14px; color: var(--muted); margin: 0 0 6px; }

.format-list { list-style: none; padding: 0; margin: 0; }
.format-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.format-item:last-child { border-bottom: none; }
.format-name { font-weight: 600; min-width: 100px; }
.format-item .muted { flex: 1; }

@media (max-width: 700px) {
  .post-detail { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- milestone 3 */

.render-proof { display: flex; gap: 32px; flex-wrap: wrap; margin: 24px 0; }
.proof-col { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.proof-col h2 { font-size: 14px; color: var(--muted); margin: 0; }

.canvas-frame {
  background: #000;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.centered-text { text-align: center; }

/* ---------------------------------------------------------------- milestone 4: editor */

/* The editor owns the full viewport; undo the ordinary page container. */
.page:has(.editor) {
  max-width: none;
  padding: 0;
  height: calc(100vh - 57px);
  overflow: hidden;
}

.editor {
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  height: 100%;
  min-height: 0;
}

.editor-rail {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
  min-height: 0;
}
.editor-rail-right { border-right: none; border-left: 1px solid var(--line); }

.rail-back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 14px;
}
.rail-back:hover { color: var(--text); }

.rail-title { font-size: 15px; margin: 0 0 16px; }

.rail-section { margin-bottom: 22px; }
.rail-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 8px;
}

.btn-block { width: 100%; }

.page-list, .layer-list { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 4px; }

.page-item, .layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid transparent;
}
.page-item:hover, .layer-item:hover { background: #1d2230; }
.page-item.is-active, .layer-item.is-selected { background: rgba(76,141,255,0.14); border-color: rgba(76,141,255,0.4); }

.page-item .page-num { font-weight: 600; min-width: 18px; }
.page-item .page-duration-tag { color: var(--muted); font-size: 11px; margin-left: auto; }
.page-item .page-del {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 4px;
}
.page-item .page-del:hover { color: var(--error); }

.layer-item .layer-type-icon {
  width: 18px; height: 18px;
  border-radius: 4px;
  display: grid; place-items: center;
  font-size: 10px;
  background: #262b35;
  color: var(--muted);
  flex-shrink: 0;
}
.layer-item .layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-item .layer-hide-toggle { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; }

.add-layer-row { display: flex; gap: 6px; flex-wrap: wrap; }
.add-layer-row .btn { flex: 1; font-size: 12px; padding: 7px 8px; }

.editor-canvas-area { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
.toolbar-group { display: flex; align-items: center; gap: 10px; }
.toolbar-group:last-child { margin-left: auto; }
.toolbar-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 0; }
.toolbar-input { width: 64px; padding: 6px 8px; }
.save-status { font-size: 12px; color: var(--muted); min-width: 60px; }

.canvas-stage {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, #1a1d24 25%, transparent 25%), linear-gradient(-45deg, #1a1d24 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1d24 75%), linear-gradient(-45deg, transparent 75%, #1a1d24 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: #101319;
  padding: 40px;
}

.canvas-wrap { position: relative; box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(0,0,0,0.5); }
.canvas-wrap iframe { display: block; border: 0; background: #000; }

.canvas-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.handle {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px solid rgba(76,141,255,0.55);
  cursor: move;
  touch-action: none;
}
.handle.is-selected { border-color: #4c8dff; box-shadow: 0 0 0 1px rgba(76,141,255,0.3); }
.handle.is-locked { cursor: default; border-color: rgba(255,255,255,0.15); }

.resize-handle {
  position: absolute;
  width: 9px; height: 9px;
  background: #4c8dff;
  border: 1.5px solid #0b1220;
  border-radius: 2px;
  touch-action: none;
}
.resize-handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }

.snap-line {
  position: absolute;
  background: #ff5f8f;
  pointer-events: none;
  z-index: 50;
}
.snap-line.v { width: 1px; top: 0; bottom: 0; }
.snap-line.h { height: 1px; left: 0; right: 0; }

.group-outline {
  position: absolute;
  border: 1px dashed rgba(255,255,255,0.4);
  pointer-events: none;
}

/* Properties panel */
.prop-group { margin-bottom: 18px; }
.prop-group h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 8px;
}
.prop-row { display: flex; gap: 8px; margin-bottom: 8px; }
.prop-field { flex: 1; min-width: 0; }
.prop-field label { margin: 0 0 4px; font-size: 11px; }
.prop-field input, .prop-field select, .prop-field textarea {
  width: 100%;
  padding: 7px 8px;
  font-size: 13px;
}
.prop-field textarea { resize: vertical; min-height: 56px; font-family: inherit; }
.prop-check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 0 0 8px; }
.prop-check input { width: auto; }

.binding-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #1d2230;
  color: var(--muted);
  margin-bottom: 10px;
}
.binding-badge.is-linked { color: var(--ok); }
.binding-badge button {
  background: none; border: none; color: var(--accent); cursor: pointer; font-size: 11px; padding: 0;
  text-decoration: underline;
}

.layer-actions { display: flex; gap: 6px; margin-top: 4px; }
.layer-actions .btn { flex: 1; font-size: 12px; padding: 7px 6px; }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .editor-rail { max-height: 200px; }
}

/* ---------------------------------------------------------------- milestone 5 */

.font-licence-notice { margin-top: 14px; }

.font-list { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-direction: column; gap: 10px; }
.font-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.font-preview { font-size: 20px; min-width: 220px; }
.font-meta { flex: 1; display: flex; flex-direction: column; gap: 2px; }

/* Preset picker modal, opened from the editor toolbar */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5,7,12,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 480px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 20px;
}
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.modal-close { float: right; background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }

.preset-group-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  margin: 16px 0 8px;
}
.preset-group-title:first-child { margin-top: 0; }

.preset-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.preset-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.preset-item .preset-name { flex: 1; font-size: 14px; }
.preset-item .btn { font-size: 12px; padding: 6px 10px; }

/* ---------------------------------------------------------------- milestone 7 */

.export-checks { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.export-check {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  min-width: 140px;
}
.export-check input { width: auto; margin-bottom: 4px; }

.export-status { margin-top: 18px; display: flex; align-items: center; gap: 12px; }

.job-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.job-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.job-item:last-child { border-bottom: none; }
.job-status { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: #1d2230; }
.job-status-done { color: var(--ok); }
.job-status-failed { color: var(--error); }
.job-status-running, .job-status-queued { color: var(--accent); }
.job-error { flex: 1; }

/* ---------------------------------------------------------------- milestone 8 */

.reel-toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
  background: #12151c;
  flex-wrap: wrap;
}
.reel-toolbar .toolbar-group:first-child { flex: 1; min-width: 260px; }
.reel-toolbar #timeline-scrubber { flex: 1; }
.timeline-time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); min-width: 44px; }
.btn-icon { width: 30px; padding: 6px 0; text-align: center; }

.duration-warn { color: #ffb454; }

.anim-phase { margin-bottom: 14px; padding: 10px 12px; background: #14181f; border-radius: 8px; }
.anim-phase h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 8px; }

.anim-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin: 22px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
