/* ==========================================================================
   Ndot Logo Generator — main stylesheet
   ========================================================================== */

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

:root {
  --bg:          #080808;
  --panel:       #0e0e0e;
  --panel2:      #121212;
  --border:      #222;
  --border-hi:   #3a3a3a;
  --text:        #d8d8d8;
  --text-mid:    #888;
  --text-dim:    #777;
  --text-dimmer: #585858;
  --input-bg:    #131313;
  --tag-bg:      #161616;
  --sidebar-w:   320px;
  --focus:       #6aa9ff;
  --accent:      #d71921; /* Nothing red */
  --danger:      #ff5b5b;
  --header-h:    46px;
  --footer-h:    58px;
  --font-mono:   'NType82Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
  --font-display:'Ndot57', var(--font-mono);   /* h1 / h2 / section labels */
}

html, body {
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
}

html { height: 100%; }
body { height: 100%; overflow: hidden; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.noscript-note {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text); font-size: 13px; text-align: center; padding: 24px;
}

/* ── SHELL ── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 4px 1fr;
  grid-template-rows: var(--header-h) 1fr var(--footer-h);
  height: 100vh;
  height: 100dvh;
}

/* ── HEADER ── */
.header {
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
}
.header-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 22px;
  border-right: 1px solid var(--border);
  width: var(--sidebar-w);
  flex-shrink: 0;
  gap: 4px;
}
.header-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
}
.header-sub {
  font-size: 9px;
  color: var(--text-dimmer);
  letter-spacing: 0.1em;
  line-height: 1;
}
.header-right {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  min-width: 0;
}
.header-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.header-meta {
  font-size: 10px; color: var(--text-dimmer); letter-spacing: 0.08em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header-actions { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }
.ghost-btn {
  background: var(--tag-bg); border: 1px solid var(--border); border-radius: 3px;
  color: var(--text-dim); font-family: inherit; font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 6px 11px; cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.ghost-btn:hover, .ghost-btn:focus-visible { color: var(--text); border-color: var(--border-hi); }
/* Reset waiting for its second click. */
.ghost-btn.armed { color: #ff8a8a; border-color: var(--accent); background: #2a0f11; }

/* ── RESIZE HANDLE ── */
.resize-handle {
  grid-row: 2 / 3;
  grid-column: 2;
  background: transparent;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
  border: none;
  padding: 0;
}
.resize-handle::after {
  content: '';
  width: 1px;
  height: 100%;
  background: var(--border);
  transition: background 0.15s, width 0.15s;
}
.resize-handle:hover::after,
.resize-handle:focus-visible::after,
.resize-handle.dragging::after {
  background: var(--border-hi);
  width: 2px;
}

/* ── SIDEBAR ── */
.sidebar {
  grid-row: 2;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Ndot is dot-matrix, so headings run a little larger to stay legible. */
.sec-label, .size-tabs-label, .dl-dropdown-label {
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  color: var(--text-dim);
}
.sec-label {
  font-size: 12px;
  letter-spacing: 0.16em;
  padding: 13px 2px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}
.sec-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* BG / PRESET CARDS */
.bg-card { border: 1px solid var(--border); border-radius: 5px; background: var(--panel); padding: 10px 12px; display: flex; flex-direction: column; gap: 9px; }
.bg-card-row { display: flex; align-items: center; gap: 8px; }
.bg-card-label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); flex: 1; }

.check-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check-row input[type="checkbox"] {
  width: 13px; height: 13px; flex-shrink: 0; margin: 0;
  accent-color: var(--accent); cursor: pointer;
}

/* Grid, not flex-wrap, so a lone button on the last row keeps its width. */
.preset-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 6px; }
.preset-btn {
  min-width: 0;
  background: var(--tag-bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-dim); font-family: inherit; font-size: 9px; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 7px 8px; cursor: pointer; text-align: center;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.preset-btn:hover, .preset-btn:focus-visible { color: var(--text); border-color: var(--border-hi); }
.preset-btn[aria-pressed="true"] { color: var(--text); border-color: var(--border-hi); background: #1e1e1e; }
.preset-dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid #333; flex-shrink: 0; }

/* LINE CARD */
.line-card { border: 1px solid var(--border); border-radius: 5px; background: var(--panel); overflow: hidden; }
.line-card + .line-card { margin-top: 5px; }
.line-card.drag-over { border-color: var(--accent); }
.line-card.dragging  { opacity: 0.35; }

.line-card-header {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 11px 8px 9px;
  border-bottom: 1px solid var(--border);
  background: var(--panel2);
}
.drag-handle {
  display: flex; flex-direction: column; gap: 2.5px; flex-shrink: 0;
  cursor: grab; background: none; border: none; padding: 2px;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle span { display: block; width: 13px; height: 1.5px; border-radius: 1px; background: var(--text-dimmer); }
.line-label { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-mid); flex: 1; }
.order-btn, .remove-btn {
  background: none; border: none; color: var(--text-dimmer); cursor: pointer; transition: color 0.1s;
  display: flex; align-items: center; justify-content: center;
}
.order-btn { font-size: 11px; padding: 2px 4px; }
.remove-btn { font-size: 15px; line-height: 1; padding: 0 1px; }
.order-btn:hover, .order-btn:focus-visible, .remove-btn:hover, .remove-btn:focus-visible { color: #aaa; }
.order-btn:disabled { opacity: 0.25; cursor: default; }
.order-btn:disabled:hover { color: var(--text-dimmer); }
.line-card-body { padding: 11px 12px; display: flex; flex-direction: column; gap: 9px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > label, .slider-row > label {
  font-size: 9px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--text-dim);
}
input[type="text"], select {
  background: var(--input-bg); border: 1px solid #222; border-radius: 3px;
  color: var(--text); font-family: inherit; font-size: 12px; padding: 6px 9px;
  outline: none; width: 100%; -webkit-appearance: none; appearance: none;
  transition: border-color 0.12s, color 0.12s;
}
input[type="text"]:focus, select:focus { border-color: var(--border-hi); color: #fff; }
input[type="text"]::placeholder { color: #2f2f2f; }
input[type="text"].invalid { border-color: var(--danger); color: var(--danger); }
select { cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none' stroke='%23777' stroke-width='1.5'%3E%3Cpath d='M2 3.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; padding-right: 26px;
}
select option { background: #131313; color: var(--text); }

.slider-row { display: flex; flex-direction: column; gap: 4px; }
.slider-track { display: flex; align-items: center; gap: 7px; }
input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none; height: 2px; background: #242424;
  border-radius: 2px; outline: none; cursor: pointer;
  padding: 0; width: auto; border: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 13px; height: 13px;
  border-radius: 50%; background: #555; cursor: pointer; transition: background 0.12s; border: none;
}
input[type="range"]::-webkit-slider-thumb:hover { background: #bbb; }
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: none;
  border-radius: 50%; background: #555; cursor: pointer; transition: background 0.12s;
}
input[type="range"]::-moz-range-thumb:hover { background: #bbb; }
input[type="range"]::-moz-range-track { height: 2px; background: #242424; border-radius: 2px; }
.slider-val { font-size: 10px; color: var(--text-mid); width: 34px; text-align: right; flex-shrink: 0; }
.step-btns { display: flex; gap: 2px; margin-top: 1px; }
.step-btn {
  background: var(--tag-bg); border: 1px solid var(--border); border-radius: 2px;
  color: var(--text-dim); font-family: inherit; font-size: 9px; padding: 3px 0;
  cursor: pointer; flex: 1; text-align: center; transition: color 0.1s, border-color 0.1s;
}
.step-btn:hover, .step-btn:focus-visible { color: var(--text); border-color: var(--border-hi); }

.color-row { display: flex; align-items: center; gap: 6px; }
.color-swatch { width: 26px; height: 26px; border-radius: 3px; border: 1px solid #2e2e2e; cursor: pointer; flex-shrink: 0; position: relative; overflow: hidden; }
.color-swatch input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: none; padding: 0; }
.hex-input { font-size: 11px !important; padding: 4px 7px !important; letter-spacing: 0.06em; text-transform: uppercase; }

.add-line-btn {
  background: var(--tag-bg); border: 1px dashed var(--border); border-radius: 5px;
  color: var(--text-dim); font-family: inherit; font-size: 11px;
  padding: 9px 12px; cursor: pointer; width: 100%; text-align: left;
  letter-spacing: 0.06em; transition: color 0.12s, border-color 0.12s;
  margin-top: 5px;
}
.add-line-btn:hover, .add-line-btn:focus-visible { color: var(--text); border-color: var(--border-hi); }

.credit-card { border: 1px solid var(--border); border-radius: 5px; background: var(--panel); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.credit-card-header { display: flex; align-items: center; justify-content: space-between; }
.credit-row { display: flex; align-items: center; gap: 5px; }
.credit-row + .credit-row { margin-top: 6px; }
.credit-row input[type="text"].credit-text { flex: 1; min-width: 0; }
.credit-remove-btn { background: none; border: none; color: var(--text-dimmer); font-size: 14px; cursor: pointer; transition: color 0.12s; flex-shrink: 0; }
.credit-remove-btn:hover, .credit-remove-btn:focus-visible { color: #aaa; }
.add-credit-btn {
  background: none; border: none; color: var(--text-dim);
  font-family: inherit; font-size: 10px; letter-spacing: 0.1em;
  cursor: pointer; padding: 0; transition: color 0.12s; align-self: flex-start;
}
.add-credit-btn:hover, .add-credit-btn:focus-visible { color: var(--text); }
.hint { font-size: 9px; color: var(--text-dimmer); letter-spacing: 0.04em; line-height: 1.5; }

/* ── MAIN ── */
.main {
  grid-row: 2;
  grid-column: 3;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px; overflow: hidden; padding: 24px;
  position: relative;
  background:
    radial-gradient(circle at 1px 1px, #141414 1px, transparent 0);
  background-size: 22px 22px;
}

.size-tabs-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.size-tabs-label { font-size: 11px; letter-spacing: 0.16em; color: var(--text-dimmer); line-height: 1; }
.size-tabs { display: flex; gap: 3px; background: var(--panel2); border: 1px solid var(--border); border-radius: 5px; padding: 3px; flex-wrap: wrap; justify-content: center; }
.size-tab {
  background: transparent; border: 1px solid transparent; border-radius: 3px;
  color: var(--text-dim); font-family: inherit; font-size: 10px;
  padding: 4px 11px; cursor: pointer; letter-spacing: 0.06em;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.size-tab:hover { color: var(--text-mid); }
.size-tab.active { background: #1e1e1e; border-color: var(--border-hi); color: var(--text); }

.canvas-outer { position: relative; display: flex; align-items: flex-start; justify-content: flex-start; }
.canvas-badge { position: absolute; top: -20px; right: 0; font-size: 9px; color: var(--text-dimmer); letter-spacing: 0.12em; pointer-events: none; }
.logo-box {
  width: 512px; height: 512px;
  background: #000;
  display: flex; flex-direction: column;
  align-items: flex-start; justify-content: center;
  padding: 0 56px; overflow: hidden;
  outline: 1px solid #2a2a2a;
  transform-origin: top left;
  flex-shrink: 0;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
/* Checkerboard = transparent export. */
.logo-box.transparent {
  background-color: #6e6e6e;
  background-image:
    linear-gradient(45deg, #4a4a4a 25%, transparent 25%, transparent 75%, #4a4a4a 75%),
    linear-gradient(45deg, #4a4a4a 25%, transparent 25%, transparent 75%, #4a4a4a 75%);
  background-size: 32px 32px;
  background-position: 0 0, 16px 16px;
}
.logo-line { display: block; white-space: nowrap; letter-spacing: 0.03em; transform-origin: left center; }
.logo-credits { margin-top: 10px; }
.logo-credit-line { font-family: 'NType82Mono', monospace; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; display: block; line-height: 1.5; white-space: nowrap; }

/* ── FOOTER ── */
.footer { grid-column: 1 / -1; border-top: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; gap: 12px; }
.footer-credits { font-size: 9px; color: var(--text-dimmer); letter-spacing: 0.06em; flex: 1; line-height: 1.9; min-width: 0; }
.footer-credits a { color: #555; text-decoration: none; transition: color 0.12s; }
.footer-credits a:hover, .footer-credits a:focus-visible { color: #999; }

.dl-wrap { position: relative; display: flex; align-items: center; }
.dl-btn-main {
  background: #181818; border: 1px solid #303030; border-right: none; border-radius: 4px 0 0 4px;
  color: var(--text); font-family: inherit; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 0 16px; height: 32px; cursor: pointer; display: flex; align-items: center; gap: 7px;
  transition: background 0.12s, border-color 0.12s; white-space: nowrap;
}
.dl-btn-main:hover { background: #222; border-color: #555; }
.dl-btn-main:disabled { opacity: 0.6; cursor: progress; }
.dl-btn-main svg { width: 11px; height: 11px; flex-shrink: 0; }
.dl-size-badge { font-size: 9px; color: var(--text-dim); letter-spacing: 0.06em; margin-left: 1px; }

.dl-arrow-btn {
  background: #181818; border: 1px solid #303030; border-radius: 0 4px 4px 0;
  color: var(--text-dim); font-family: inherit; font-size: 10px; padding: 0 9px; height: 32px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s; border-left: 1px solid #252525;
}
.dl-arrow-btn:hover { background: #222; border-color: #555; color: var(--text); }
.dl-arrow-btn svg { width: 10px; height: 10px; transition: transform 0.15s; }
.dl-arrow-btn[aria-expanded="true"] svg { transform: rotate(180deg); }

.dl-dropdown {
  position: absolute; bottom: calc(100% + 6px); right: 0;
  background: #111; border: 1px solid var(--border-hi); border-radius: 5px; min-width: 200px;
  overflow: hidden; opacity: 0; pointer-events: none; transform: translateY(6px);
  transition: opacity 0.15s, transform 0.15s; z-index: 100;
}
.dl-dropdown.open { opacity: 1; pointer-events: all; transform: translateY(0); }
.dl-dropdown-label { font-size: 11px; letter-spacing: 0.14em; color: var(--text-dimmer); padding: 9px 13px 6px; border-bottom: 1px solid var(--border); line-height: 1; }
.dl-option {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 13px; cursor: pointer;
  font-size: 11px; color: var(--text-mid); letter-spacing: 0.06em; transition: background 0.08s, color 0.08s;
  border: none; background: none; font-family: inherit; width: 100%;
}
.dl-option:hover, .dl-option:focus-visible { background: #1a1a1a; color: var(--text); }
.dl-option[aria-checked="true"] { color: var(--text); }
.dl-option .dl-opt-size { font-size: 9px; color: var(--text-dimmer); }
.dl-option[aria-checked="true"] .dl-opt-size { color: var(--text-dim); }
.dl-option .dl-check { opacity: 0; font-size: 10px; color: var(--accent); }
.dl-option[aria-checked="true"] .dl-check { opacity: 1; }

.dl-format-row { display: flex; gap: 3px; padding: 7px 13px; border-top: 1px solid var(--border); }
.dl-format-btn {
  flex: 1; background: var(--tag-bg); border: 1px solid var(--border); border-radius: 3px;
  color: var(--text-dim); font-family: inherit; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 5px 0; cursor: pointer; transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.dl-format-btn[aria-pressed="true"] { color: var(--text); border-color: var(--border-hi); background: #1e1e1e; }
.dl-format-btn:hover { color: var(--text); }

.dl-custom-row { display: flex; align-items: center; gap: 0; border-top: 1px solid var(--border); padding: 7px 13px; }
.dl-custom-label { font-size: 9px; color: var(--text-dimmer); letter-spacing: 0.1em; flex: 1; }
.dl-custom-input {
  background: #1a1a1a !important; border: 1px solid #2a2a2a !important; border-radius: 3px !important;
  width: 66px !important; font-size: 11px !important; color: var(--text-mid) !important; padding: 3px 6px !important;
  text-align: right;
}
.dl-custom-input:focus { color: var(--text) !important; border-color: var(--border-hi) !important; }
.dl-custom-input.invalid { border-color: var(--danger) !important; color: var(--danger) !important; }
.dl-custom-px { font-size: 9px; color: var(--text-dimmer); margin-left: 4px; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #262626; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #333; }

body.resizing { cursor: col-resize !important; user-select: none !important; }
body.resizing * { pointer-events: none !important; }
body.resizing .resize-handle { pointer-events: all !important; }

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

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 74px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: #161616; border: 1px solid var(--border-hi); border-radius: 5px;
  color: var(--text); font-size: 11px; letter-spacing: 0.06em; padding: 9px 16px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 200;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── MOBILE / RESPONSIVE ── */
@media (max-width: 820px) {
  body { overflow: auto; }
  .shell {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }
  .header { flex-wrap: wrap; }
  .header-brand { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 10px 18px; }
  .header-right { padding: 8px 18px; width: 100%; }
  .header-meta { display: none; }
  .header-actions { margin-left: 0; }

  .resize-handle { display: none; }

  .main {
    order: -1;
    min-height: 62vh;
    padding: 20px 16px;
  }
  .sidebar { overflow: visible; }
  .sidebar-scroll { overflow: visible; padding: 12px 14px 24px; }

  .footer { flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  .footer-credits { flex: 1 1 100%; order: 2; text-align: center; }
  .dl-wrap { flex: 1 1 100%; order: 1; }
  .dl-btn-main { flex: 1; justify-content: center; }
  .toast { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
