/* ══════════════════════════════════════════
   cinematography.tools — Stylesheet
   Matches Lína design system
   ══════════════════════════════════════════ */

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

:root {
  --bg-body: #111115;
  --bg-panel: #1a1a20;
  --bg-card: #22222a;
  --bg-card-hover: #2a2a33;
  --bg-input: #1a1a1f;
  --border: #333340;
  --border-light: #444455;
  --border-hover: #555566;
  --accent: #d18b3c;
  --accent-hover: #e09b4c;
  --accent-dim: rgba(209, 139, 60, 0.15);
  --text: #e8e8ec;
  --text-secondary: #9999a8;
  --text-muted: #66667a;
  --success: #2ecc71;
  --info: #3498db;
  --font-display: 'Staatliches', cursive;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --sidebar-width: 260px;
  --header-height: 56px;
  --radius: 6px;
  --radius-lg: 10px;
}

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Noise texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.02;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
::selection { background: var(--accent); color: #fff; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ─── HEADER ─── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: rgba(17, 17, 21, 0.92);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; z-index: 100; gap: 16px;
}
.header-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.header-logo {
  width: 28px; height: 28px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #a06828);
  display: flex; align-items: center; justify-content: center;
}
.header-logo svg { width: 16px; height: 16px; }
.header-title { font-family: var(--font-display); font-size: 22px; letter-spacing: 0.02em; color: var(--text); line-height: 1; }
.header-title span { color: var(--accent); }
.header-subtitle { font-size: 11px; color: var(--text-muted); letter-spacing: 0.03em; text-transform: uppercase; display: none; }
@media (min-width: 768px) { .header-subtitle { display: block; } }
.hamburger {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; background: none;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-secondary); cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.hamburger:hover { background: var(--bg-card); color: var(--text); border-color: var(--border-light); }
.hamburger svg { width: 18px; height: 18px; }
@media (min-width: 960px) { .hamburger { display: none; } }
.header-spacer { flex: 1; }
.header-link { font-size: 12px; color: var(--text-muted); transition: color 0.15s; white-space: nowrap; }
.header-link:hover { color: var(--accent); }

/* ─── SIDEBAR ─── */
.sidebar {
  position: fixed; top: var(--header-height); left: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--bg-panel);
  border-right: 1px solid var(--border); overflow-y: auto; z-index: 90;
  padding: 12px 0; transform: translateX(-100%); transition: transform 0.25s ease;
}
.sidebar.open { transform: translateX(0); }
@media (min-width: 960px) { .sidebar { transform: translateX(0); } }
.sidebar-overlay { display: none; position: fixed; inset: 0; top: var(--header-height); background: rgba(0,0,0,0.5); z-index: 89; }
.sidebar-overlay.show { display: block; }
@media (min-width: 960px) { .sidebar-overlay { display: none !important; } }
.sidebar-section { padding: 8px 12px 4px; }
.sidebar-section-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); padding: 8px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px; margin: 1px 8px;
  border-radius: var(--radius); font-size: 13px; font-weight: 400; color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s; border: 1px solid transparent; user-select: none;
}
.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); border-color: rgba(209,139,60,0.2); font-weight: 500; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }

/* ─── CANVAS ─── */
.canvas { position: fixed; top: var(--header-height); left: 0; right: 0; bottom: 0; overflow-y: auto; padding: 32px 24px 60px; transition: left 0.25s ease; }
@media (min-width: 960px) { .canvas { left: var(--sidebar-width); } }
.canvas-inner { max-width: 900px; margin: 0 auto; }

/* ─── TOOL VIEWS ─── */
.tool-view { display: none; animation: fadeIn 0.2s ease; }
.tool-view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.tool-header { margin-bottom: 28px; }
.tool-header h1 { font-family: var(--font-display); font-size: 32px; letter-spacing: 0.01em; line-height: 1.1; }
.tool-header p { margin-top: 8px; font-size: 14px; color: var(--text-secondary); max-width: 600px; line-height: 1.6; }

/* ─── PANELS ─── */
.panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 20px; }
.panel-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 16px; }

/* ─── FORMS ─── */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 600px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid.three-col { grid-template-columns: 1fr 1fr 1fr; } }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0.02em; }
select, input[type="number"], input[type="text"] {
  font-family: var(--font-body); font-size: 14px; padding: 9px 12px;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); outline: none; transition: border-color 0.15s, box-shadow 0.15s; width: 100%;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
select {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239999a8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}

/* Range slider */
input[type="range"] { -webkit-appearance: none; width: 100%; height: 4px; border-radius: 2px; background: var(--border); outline: none; margin: 8px 0; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid var(--bg-panel); box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid var(--bg-panel); }
.range-display { display: flex; align-items: center; gap: 12px; }
.range-display input[type="range"] { flex: 1; }
.range-val { font-size: 14px; font-weight: 600; color: var(--accent); min-width: 60px; text-align: right; font-variant-numeric: tabular-nums; }

/* ─── RESULTS ─── */
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.result-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; text-align: center; }
.result-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 4px; }
.result-value { font-size: 22px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.result-unit { font-size: 12px; color: var(--text-secondary); font-weight: 400; }
.result-note { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ─── DOF DIAGRAM ─── */
.dof-diagram { width: 100%; height: 80px; position: relative; margin: 20px 0 8px; }

/* FoV Diagram */
.fov-diagram { width: 100%; margin: 20px 0 8px; }
.fov-diagram svg { width: 100%; height: auto; display: block; }
.fov-diagram .fov-cone { fill: var(--accent); opacity: 0.08; }
.fov-diagram .fov-cone-edge { stroke: var(--accent); stroke-width: 1.5; fill: none; opacity: 0.5; }
.fov-diagram .fov-arc { stroke: var(--accent); stroke-width: 1.5; fill: none; opacity: 0.6; }
.fov-diagram .fov-coverage { stroke: var(--accent); stroke-width: 2; fill: var(--accent); fill-opacity: 0.12; }
.fov-diagram .fov-centerline { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 3; opacity: 0.4; }
.fov-diagram .fov-camera { fill: var(--text-secondary); }
.fov-diagram .fov-label { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.fov-diagram .fov-label-accent { fill: var(--accent); font-size: 11px; font-family: inherit; font-weight: 500; }
.fov-diagram .fov-distance-line { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2 2; opacity: 0.3; }
.dof-bar { position: absolute; top: 24px; height: 24px; border-radius: 4px; transition: all 0.3s ease; }
.dof-bar.total { background: var(--bg-card-hover); left: 0; right: 0; border: 1px solid var(--border); }
.dof-bar.sharp { background: linear-gradient(90deg, rgba(209,139,60,0.08), rgba(209,139,60,0.25), rgba(209,139,60,0.08)); border: 1px solid var(--accent); }
.dof-marker { position: absolute; top: 14px; width: 2px; height: 44px; background: var(--accent); transform: translateX(-50%); }
.dof-marker.subject { background: var(--accent); }
.dof-marker.near-mark, .dof-marker.far-mark { background: var(--text-muted); width: 1px; height: 36px; top: 18px; }
.dof-label { position: absolute; top: 64px; font-size: 10px; color: var(--text-muted); transform: translateX(-50%); white-space: nowrap; }
.dof-label.subject-label { color: var(--accent); font-weight: 600; }
.dof-label .dist-val { display: block; font-variant-numeric: tabular-nums; }

/* ─── ASPECT RATIO ─── */
.aspect-box { border: 2px solid var(--accent); background: rgba(209,139,60,0.05); transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--accent); font-weight: 500; }
.aspect-compare-box { border: 2px dashed var(--border-light); background: rgba(255,255,255,0.02); position: absolute; transition: all 0.3s ease; }
.visual-preview { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; justify-content: center; min-height: 200px; position: relative; overflow: hidden; }

/* ─── TIMECODE ─── */
.timecode-display { font-family: 'Courier New', monospace; font-size: 36px; font-weight: 700; color: var(--accent); text-align: center; padding: 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); letter-spacing: 0.05em; margin: 16px 0; }

/* ─── MISC ─── */
.info-callout { background: rgba(52,152,219,0.08); border: 1px solid rgba(52,152,219,0.2); border-radius: var(--radius); padding: 12px 16px; font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin: 12px 0; }
.info-callout strong { color: var(--info); }
.btn { font-family: var(--font-body); font-size: 13px; font-weight: 500; padding: 9px 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-card); color: var(--text); cursor: pointer; transition: all 0.15s; }
.btn:hover { background: var(--bg-card-hover); border-color: var(--border-light); }
.tool-tabs { display: flex; gap: 4px; margin-bottom: 16px; padding: 4px; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
.tool-tab { flex: 1; padding: 8px 12px; font-size: 12px; font-weight: 500; text-align: center; color: var(--text-secondary); background: transparent; border: none; border-radius: 4px; cursor: pointer; transition: all 0.15s; font-family: var(--font-body); }
.tool-tab:hover { color: var(--text); }
.tool-tab.active { background: var(--accent); color: #fff; }

/* ─── TABLES ─── */
.nd-table, .data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.nd-table th, .data-table th { text-align: left; padding: 10px 12px; background: var(--bg-card); border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
.nd-table td, .data-table td { padding: 8px 12px; border-bottom: 1px solid rgba(51,51,64,0.4); color: var(--text); }
.nd-table tr.highlight td { background: var(--accent-dim); color: var(--accent); font-weight: 500; }

/* ─── HOME GRID ─── */
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 24px; }
.home-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; cursor: pointer; transition: all 0.2s; display: flex; align-items: flex-start; gap: 14px; }
.home-card:hover { border-color: var(--accent); background: var(--bg-card); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.home-card-icon { width: 40px; height: 40px; border-radius: 8px; background: var(--accent-dim); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.home-card-icon svg { width: 20px; height: 20px; color: var(--accent); }
.home-card h3 { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.home-card p { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ─── COC OVERRIDE ─── */
.coc-override-wrap { display: flex; align-items: center; gap: 6px; }
.coc-input { width: 90px; text-align: right; }
.coc-input::placeholder { color: var(--text-muted); font-style: italic; }
.coc-reset-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 4px; width: 24px; height: 24px; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0; }
.coc-reset-btn:hover { border-color: var(--accent); color: var(--accent); }
.coc-auto-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.coc-input.overridden { border-color: var(--accent); color: var(--accent); }

/* ─── REFERENCE PAGE ─── */
.ref-section p.ref-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 20px; }
.ref-formula-block { background: var(--bg-body); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 20px; }
.ref-formula-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px; margin-top: 16px; }
.ref-formula-label:first-child { margin-top: 0; }
.ref-formula { font-family: 'Courier New', monospace; font-size: 16px; color: var(--accent); padding: 8px 0 4px; letter-spacing: 0.02em; }
.ref-formula sub, .ref-formula sup { font-size: 11px; }
.ref-formula-note { font-size: 12px; color: var(--text-muted); font-style: italic; margin-top: 4px; }
.ref-variables { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.ref-var { font-size: 13px; color: var(--text-secondary); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; line-height: 1.4; }
.ref-var span { font-family: 'Courier New', monospace; font-weight: 600; color: var(--accent); margin-right: 8px; }
p.ref-note { font-size: 13px; color: var(--text-muted); line-height: 1.7; border-left: 2px solid var(--border); padding-left: 16px; margin-top: 4px; }
p.ref-note em { color: var(--text-secondary); }
p.ref-note code { font-family: 'Courier New', monospace; font-size: 12px; color: var(--accent); background: var(--bg-card); padding: 1px 5px; border-radius: 3px; }
.ref-db-link { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--accent); padding: 10px 18px; border: 1px solid var(--accent); border-radius: var(--radius); transition: all 0.15s; }
.ref-db-link:hover { background: var(--accent-dim); color: var(--accent-hover); }

/* ─── CAMERA DATABASE TABLE ─── */
#cam-db-table { font-size: 12px; }
#cam-db-table th { white-space: nowrap; position: sticky; top: 0; z-index: 1; }
#cam-db-table th.cam-sortable { cursor: pointer; user-select: none; transition: color 0.15s; }
#cam-db-table th.cam-sortable:hover { color: var(--accent); }
#cam-db-table td { white-space: nowrap; font-variant-numeric: tabular-nums; }
#cam-db-table td strong { color: var(--text); font-weight: 500; }
#cam-db-table tbody tr { transition: background 0.1s; }
#cam-db-table tbody tr:hover { background: var(--accent-dim); }

/* ─── FOOTER ─── */
.canvas-footer { margin-top: 60px; padding: 20px 0; border-top: 1px solid var(--border); text-align: center; font-size: 12px; color: var(--text-muted); }
.canvas-footer a { color: var(--accent); }
.canvas-footer .footer-legal { margin-top: 12px; font-size: 11px; color: var(--text-muted); opacity: 0.7; line-height: 1.6; }

/* ─── MOBILE ─── */
@media (max-width: 599px) {
  .canvas { padding: 20px 16px 60px; }
  .tool-header h1 { font-size: 26px; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .result-value { font-size: 18px; }
  .timecode-display { font-size: 24px; }
  .panel { padding: 18px; }
}
