/* Crayon Shark — one accent color: the shark blue. */

:root {
  --accent: #4677ad;
  --accent-strong: #3a6698;
  --accent-soft: #e7eef6;
  --on-accent: #ffffff;

  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f1eee8;
  --ink: #1e2227;
  --ink-2: #565d66;
  --ink-3: #82888f;
  --line: #e3dfd7;
  --check-a: #ffffff;
  --check-b: #f2efea;
  --swatch-edge: rgb(0 0 0 / 0.12);
  --shadow: 0 1px 2px rgb(30 34 39 / 0.05), 0 6px 24px rgb(30 34 39 / 0.06);

  --radius: 20px;
  --font-display: "Fredoka", "Zen Maru Gothic", ui-rounded, "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  --font-body: "Nunito", "Zen Maru Gothic", ui-rounded, "Hiragino Maru Gothic ProN", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #6f9fd4;
    --accent-strong: #93b9e3;
    --accent-soft: rgb(111 159 212 / 0.16);
    --on-accent: #0e1824;
    --bg: #111316;
    --surface: #191c20;
    --surface-2: #23272c;
    --ink: #eceef0;
    --ink-2: #a9afb7;
    --ink-3: #7d838c;
    --line: #2d3238;
    --check-a: #1d2024;
    --check-b: #23272b;
    --swatch-edge: rgb(255 255 255 / 0.18);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 28px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --accent: #6f9fd4;
  --accent-strong: #93b9e3;
  --accent-soft: rgb(111 159 212 / 0.16);
  --on-accent: #0e1824;
  --bg: #111316;
  --surface: #191c20;
  --surface-2: #23272c;
  --ink: #eceef0;
  --ink-2: #a9afb7;
  --ink-3: #7d838c;
  --line: #2d3238;
  --check-a: #1d2024;
  --check-b: #23272b;
  --swatch-edge: rgb(255 255 255 / 0.18);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 28px rgb(0 0 0 / 0.25);
  color-scheme: dark;
}

/* ---------- base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

:lang(ja) body {
  font-feature-settings: "palt";
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.005em;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- header / footer ---------- */

.site-header,
.site-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding-inline: 24px;
}

.site-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 20px;
  padding-block: 16px 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: none;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  line-height: 1;
}

.tagline {
  margin: 0;
  color: var(--ink-2);
  text-align: right;
}

.seg-lang {
  padding: 3px;
  border-radius: 10px;
}

.seg-lang span {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.site-footer {
  padding-block: 4px 40px;
  color: var(--ink-3);
  font-size: 13px;
}

.site-footer p {
  margin: 0;
}

/* ---------- layout ---------- */

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 24px 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.stage-col {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 16px;
}

.controls {
  display: grid;
  gap: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head h2 {
  margin: 0;
}

/* ---------- stage ---------- */

.stage {
  padding: 14px;
}

.stage-art {
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 14px;
  background: repeating-conic-gradient(var(--check-a) 0 25%, var(--check-b) 0 50%) 0 0 / 22px 22px;
}

#preview {
  display: block;
  width: min(100%, max(260px, calc(100vh - 430px)));
  height: auto;
  aspect-ratio: 1;
}

.stage-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  padding: 10px 4px 0;
}

.actual {
  display: flex;
  align-items: center;
  gap: 12px;
}

.actual canvas {
  display: block;
  image-rendering: pixelated;
}

.actual-label {
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink-3);
}

.stage-actions {
  display: flex;
  gap: 4px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, transform 0.1s;
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.btn-secondary:hover {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

.btn-quiet {
  background: transparent;
  color: var(--ink-2);
}

.btn-quiet:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-small {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

/* ---------- fields ---------- */

.field + .field,
.field + .sliders,
.sliders + .field,
.row + .field,
.field + .row {
  margin-top: 18px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 24px;
}

.row > .field {
  margin: 0;
}

[data-needs-bg],
[data-needs-text] {
  transition: opacity 0.15s;
}

[data-needs-bg].is-off,
[data-needs-text].is-off {
  opacity: 0.4;
  pointer-events: none;
}

/* text field */

.text-input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: 700 16px/1 var(--font-body);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.text-input::placeholder {
  color: var(--ink-3);
  font-weight: 600;
}

.text-input:hover {
  border-color: var(--ink-3);
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.note {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

.note:empty {
  display: none;
}

/* each font choice is written in its own lettering */
.seg-fonts span {
  font-size: 15px;
  font-weight: 400;
}

.ff-marker {
  font-family: "Yusei Magic", var(--font-body);
}

.ff-pop {
  font-family: "Hachi Maru Pop", var(--font-body);
}

.ff-pencil {
  font-family: "Yomogi", var(--font-body);
}

/* segmented control */

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
}

.seg label {
  position: relative;
}

.seg input,
.tile input,
.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg span {
  display: block;
  padding: 6px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  text-align: center;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.seg label:hover span {
  color: var(--ink);
}

.seg input:checked + span {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1.5px var(--accent), 0 1px 2px rgb(0 0 0 / 0.06);
}

.seg input:focus-visible + span {
  outline: 2.5px solid var(--accent);
  outline-offset: 1px;
}

.seg-sizes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  width: 100%;
}

.seg-sizes span {
  padding-inline: 0;
  font-variant-numeric: tabular-nums;
}

/* picture tiles */

.pose-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 20px;
}

.pose-row > .field {
  margin: 0;
}

.tiles {
  display: grid;
  gap: 8px;
}

.tiles-pose {
  grid-template-columns: repeat(2, 132px);
}

.tiles-expr {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.tile {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  border: 1.5px solid transparent;
  border-radius: 14px;
  background: var(--surface-2);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.tile img {
  display: block;
  width: 100%;
  max-width: 64px;
  aspect-ratio: 1;
}

.tiles-pose .tile {
  grid-template-columns: 56px auto;
  justify-content: start;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
}

.tile span {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.tile:hover {
  border-color: var(--line);
}

.tile:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.tile:has(input:checked) span {
  color: var(--accent-strong);
}

.tile:has(input:focus-visible) {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* toggle chips */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  position: relative;
}

.chip span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px 0 11px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-2);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.chip span::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--ink-3);
  border-radius: 50%;
  transition: border-color 0.15s, background 0.15s;
}

.chip:hover span {
  color: var(--ink);
}

.chip input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.chip input:checked + span::before {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 0 3.5px, transparent 4px);
}

.chip input:focus-visible + span {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* color swatches */

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatch {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c, transparent);
  box-shadow: inset 0 0 0 1.5px var(--swatch-edge);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}

.swatch:hover {
  transform: scale(1.08);
}

.swatch[aria-pressed="true"],
.swatch-custom.is-on {
  box-shadow: inset 0 0 0 1.5px var(--swatch-edge), 0 0 0 2.5px var(--surface), 0 0 0 4.5px var(--accent);
}

.swatch-auto::after {
  content: "A";
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.swatch-custom {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--ink-3);
}

.swatch-custom::after {
  content: "";
  width: 12px;
  height: 12px;
  background:
    linear-gradient(var(--ink-2), var(--ink-2)) center / 12px 2px no-repeat,
    linear-gradient(var(--ink-2), var(--ink-2)) center / 2px 12px no-repeat;
}

.swatch-custom.is-on {
  background: var(--c);
}

.swatch-custom.is-on::after {
  display: none;
}

.swatch-custom input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.swatch-custom:has(input:focus-visible) {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* sliders */

.sliders {
  display: grid;
  gap: 14px;
}

.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  row-gap: 2px;
}

.slider label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.slider output {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.slider input {
  grid-column: 1 / -1;
  width: 100%;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* export */

.export-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

.export-head h2 {
  margin: 0;
}

.export-head .seg-sizes {
  flex: 1 1 300px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.check input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.check small {
  margin-left: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.export-actions .btn-primary,
.export-actions .btn-secondary {
  min-width: 112px;
}

.status {
  flex: 1 1 100%;
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}

.status:empty {
  display: none;
}

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .tiles-expr {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 880px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 4px 16px 28px;
  }

  /* Let the stage and export cards flow on their own so export can sit last. */
  .stage-col {
    display: contents;
  }

  .stage {
    order: 1;
  }

  .controls {
    order: 2;
  }

  .export {
    order: 3;
  }

  #preview {
    width: min(100%, 380px);
  }

  .site-header {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 16px 16px 8px;
  }

  .tagline {
    grid-column: 1 / -1;
    grid-row: 2;
    text-align: left;
  }

  .site-footer {
    padding-inline: 16px;
  }

  .tiles-expr {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .card {
    padding: 16px;
  }

  .tiles-expr {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tiles-pose {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .pose-row {
    display: grid;
  }

  .seg span {
    padding-inline: 11px;
  }

  .brand-name {
    font-size: 23px;
  }
}

@media (min-width: 881px) and (max-height: 720px) {
  .stage-col {
    position: static;
  }
}

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