/* Tattoo Sketcher: stencil paper, transfer ink, a little flash red. */
:root {
  --paper: #F5F6FA;
  --sheet: #FFFFFF;
  --ink: #2A2163;
  --ink-soft: #5A5480;
  --violet: #5140E0;
  --violet-wash: #ECEAFD;
  --rule: #D9D6F2;
  --flash: #C8102E;
  --flash-dark: #A00C24;
  --display: 'Pirata One', 'Iowan Old Style', Georgia, serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius-s: 6px;
  --radius-m: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.55 var(--body);
}
img, svg { display: block; max-width: 100%; }
a { color: var(--violet); text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; border-radius: 3px; }
[hidden] { display: none !important; }

h1, h2 { font-family: var(--display); font-weight: 400; line-height: 1.05; letter-spacing: 0.005em; margin: 0 0 0.4em; }
h1 { font-size: clamp(2.6rem, 6vw, 4.25rem); }
h2 { font-size: clamp(1.9rem, 3.4vw, 2.6rem); }
h3 { font-size: 1.125rem; line-height: 1.3; margin: 0 0 0.35em; }
p { margin: 0 0 1em; }

.skip-link { position: absolute; left: 1rem; top: -4rem; background: var(--ink); color: #fff; padding: 0.6rem 1rem; z-index: 10; border-radius: var(--radius-s); }
.skip-link:focus { top: 1rem; }

/* Header and footer */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  max-width: 1440px; margin: 0 auto; padding: 1rem clamp(1rem, 3vw, 2rem);
}
.brand { display: flex; align-items: center; gap: 0.5rem; color: var(--ink); text-decoration: none; font-family: var(--display); font-size: 1.75rem; }
.brand-mark { width: 28px; height: 28px; color: var(--flash); }
.site-header ul { display: flex; gap: 0.25rem 1.25rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.site-header nav a { color: var(--ink); text-decoration: none; padding: 0.35rem 0; border-bottom: 2px solid transparent; }
.site-header nav a:hover, .site-header nav a[aria-current="page"] { border-bottom-color: var(--violet); }

.site-footer { max-width: 1440px; margin: 4rem auto 0; padding: 2rem clamp(1rem, 3vw, 2rem) 3rem; border-top: 1px solid var(--rule); color: var(--ink-soft); }
.site-footer a { margin-right: 1.25rem; }
.fine { font-size: 0.875rem; }

/* Intro */
.intro { max-width: 1440px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2rem) 1.25rem; }
.lede { max-width: 62ch; font-size: 1.1875rem; color: var(--ink-soft); margin: 0; }

/* Studio layout */
.studio {
  position: relative;
  display: grid; gap: 1rem;
  grid-template-columns: minmax(230px, 270px) minmax(0, 1fr) minmax(250px, 290px);
  grid-template-areas: "add stage side";
  align-items: start;
  max-width: 1440px; margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2rem);
}
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-m); }
.panel-add { grid-area: add; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; }
.panel-side { grid-area: side; }
.stage-col { grid-area: stage; min-width: 0; }

.panel-note { font-size: 0.9rem; color: var(--ink-soft); margin: 0 0 0.75rem; }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--rule); }
.tabs button {
  font: inherit; font-size: 0.875rem; background: none; border: 0; color: var(--ink-soft);
  padding: 0.75rem 0.25rem; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--violet); }
.tabpanel { padding: 1rem; overflow-y: auto; }

.motif-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.motif-btn {
  aspect-ratio: 1; display: grid; place-items: center; padding: 0.4rem;
  background: var(--paper); border: 1px solid transparent; border-radius: var(--radius-s); cursor: pointer;
}
.motif-btn:hover { border-color: var(--violet); background: var(--violet-wash); }
.motif-btn svg { width: 100%; height: 100%; }

.font-cat { font: inherit; font-size: 0.9rem; color: var(--ink); width: 100%; padding: 0.4rem 0.5rem; margin-bottom: 0.5rem; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--sheet); }
.font-list { display: grid; gap: 0.35rem; max-height: 22rem; overflow-y: auto; padding: 2px 4px 2px 2px; overscroll-behavior: contain; }
.font-opt { display: grid; gap: 0.1rem; padding: 0.45rem 0.65rem; border: 1px solid var(--rule); border-radius: var(--radius-s); cursor: pointer; min-width: 0; }
.font-opt:has(input:checked) { border-color: var(--violet); background: var(--violet-wash); }
.font-opt input { position: absolute; opacity: 0; pointer-events: none; }
.font-opt:has(input:focus-visible) { outline: 3px solid var(--violet); outline-offset: 1px; }
.font-opt .sample { font-size: 1.5rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-opt small { color: var(--ink-soft); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tpl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.tpl-list button { width: 100%; text-align: left; font: inherit; padding: 0.65rem 0.8rem; background: var(--paper); border: 1px solid transparent; border-radius: var(--radius-s); color: var(--ink); cursor: pointer; }
.tpl-list button:hover { border-color: var(--violet); background: var(--violet-wash); }

/* Stage */
.stage-bar { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }
.bar-gap { flex: 1; }
.stage-frame {
  position: relative; max-width: min(100%, calc(100vh - 9rem)); min-width: 280px; margin: 0 auto;
  padding: 14px; background: var(--sheet); border-radius: 4px;
  box-shadow: 0 1px 0 var(--rule), 0 18px 40px -22px rgba(42, 33, 99, 0.45);
}
/* Registration marks in the corners, like a printed stencil sheet */
.stage-frame::before, .stage-frame::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border: 0 solid var(--violet);
}
.stage-frame::before { top: 3px; left: 3px; border-top-width: 2px; border-left-width: 2px; }
.stage-frame::after { bottom: 3px; right: 3px; border-bottom-width: 2px; border-right-width: 2px; }
#stage { width: 100%; height: auto; aspect-ratio: 1; touch-action: none; user-select: none; -webkit-user-select: none; cursor: default; }
#stage.is-drawing { cursor: crosshair; }
#stage .item { cursor: move; }
#stage.is-drawing .item { cursor: crosshair; }
#overlay [data-h="scale"] { cursor: nwse-resize; }
#overlay [data-h="rotate"] { cursor: grab; }
.stage-hint { font-size: 0.85rem; color: var(--ink-soft); text-align: center; margin: 0.75rem auto 0; max-width: 60ch; }
.noscript { position: absolute; inset: 14px; display: grid; place-items: center; background: rgba(255,255,255,.9); margin: 0; padding: 2rem; text-align: center; }

/* Side panel */
.side-block { padding: 1rem; border-bottom: 1px solid var(--rule); }
.side-block:last-child { border-bottom: 0; }
.side-title { font-family: var(--body); font-size: 0.95rem; font-weight: 700; letter-spacing: 0; margin: 0 0 0.6rem; }

.field { display: grid; gap: 0.3rem; margin: 0 0 0.85rem; padding: 0; border: 0; min-width: 0; font-size: 0.875rem; }
.field > span, .field legend { display: flex; justify-content: space-between; color: var(--ink); font-weight: 500; padding: 0; margin-bottom: 0.3rem; }
.field output { color: var(--ink-soft); font-variant-numeric: tabular-nums; font-weight: 400; }
.field textarea, .field select {
  font: inherit; font-size: 1rem; color: var(--ink); width: 100%;
  padding: 0.5rem 0.6rem; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--sheet);
}
.field textarea { resize: vertical; }
input[type="range"] { width: 100%; accent-color: var(--violet); margin: 0; }
.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; margin: 0 0 0.85rem; cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--violet); }

.swatches { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(42, 33, 99, 0.25); cursor: pointer; padding: 0;
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--sheet), 0 0 0 4px var(--violet); }
.swatch-custom { position: relative; overflow: hidden; background: conic-gradient(#C8102E, #F2B705, #1F7A4D, #1D4E89, #6B3FA0, #C8102E); }
.swatch-custom input { position: absolute; inset: -6px; width: 40px; height: 40px; opacity: 0; cursor: pointer; }
.skins .swatch { width: 34px; height: 34px; }

.layers { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 13rem; overflow-y: auto; }
.layer { width: 100%; text-align: left; font: inherit; font-size: 0.875rem; padding: 0.4rem 0.6rem; border: 0; border-radius: var(--radius-s); background: none; color: var(--ink); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer:hover { background: var(--paper); }
.layer.is-on { background: var(--violet-wash); font-weight: 600; }
.layers .muted { font-size: 0.875rem; color: var(--ink-soft); }

/* Buttons */
.btn-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }
.btn, .tool { font: inherit; cursor: pointer; border-radius: var(--radius-s); }
.btn { font-size: 0.95rem; font-weight: 600; padding: 0.6rem 1rem; border: 2px solid transparent; }
.btn-ink { background: var(--ink); color: #fff; width: 100%; }
.btn-ink:hover, .btn-ink[aria-pressed="true"] { background: var(--violet); }
.btn-flash { background: var(--flash); color: #fff; flex: 1; }
.btn-flash:hover { background: var(--flash-dark); }
.btn-ghost { background: none; border-color: var(--ink); color: var(--ink); flex: 1; }
.btn-ghost:hover { background: var(--ink); color: #fff; }
.tool { font-size: 0.85rem; padding: 0.4rem 0.75rem; background: var(--sheet); color: var(--ink); border: 1px solid var(--rule); }
.tool:hover:not(:disabled) { border-color: var(--violet); }
.tool:disabled { opacity: 0.45; cursor: default; }
.tool[aria-pressed="true"] { background: var(--violet); border-color: var(--violet); color: #fff; }
.tool-danger { color: var(--flash); }
.tool-danger:hover:not(:disabled) { border-color: var(--flash); }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 0.65rem 1.1rem; border-radius: var(--radius-s); font-size: 0.9rem;
  transition: opacity 0.2s, transform 0.2s; z-index: 20; max-width: calc(100vw - 2rem);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Content sections */
.content { max-width: 1100px; margin: 0 auto; padding: 4rem clamp(1rem, 3vw, 2rem) 0; }
.steps { list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2rem; margin: 1.5rem 0 0; padding: 0; }
.steps li { counter-increment: step; }
.steps li::before { content: counter(step); display: block; font-family: var(--display); font-size: 3rem; line-height: 1; color: var(--flash); margin-bottom: 0.4rem; }
.steps p, .guide p, .facts li { color: var(--ink-soft); }
.content-split { display: grid; grid-template-columns: 1.2fr 1fr; gap: 2.5rem; align-items: start; }
.content-split p { max-width: 62ch; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; border-left: 3px solid var(--violet); padding-left: 1.25rem; }
.facts strong { color: var(--ink); }
.guides { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.guide { display: block; padding: 1.25rem 1.4rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-m); text-decoration: none; color: var(--ink); }
.guide:hover { border-color: var(--violet); color: var(--ink); }
.guide h3 { color: var(--violet); font-size: 1.25rem; }
.guide p { margin: 0; }
.faq details { border-bottom: 1px solid var(--rule); padding: 0.9rem 0; max-width: 70ch; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 0.6rem 0 0; color: var(--ink-soft); }

/* Article pages */
.article { max-width: 70ch; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2rem) 0; font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif; font-size: 1.15rem; line-height: 1.65; }
.article h1 { margin-bottom: 0.3em; }
.article h2 { margin-top: 1.6em; }
.article .lede { font-family: inherit; font-size: 1.25rem; }
.article ul { padding-left: 1.2em; }
.article li { margin-bottom: 0.4em; }
.crumbs { font-family: var(--body); font-size: 0.875rem; color: var(--ink-soft); margin-bottom: 1rem; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; }
.crumbs li + li::before { content: "/"; margin-right: 0.4rem; color: var(--rule); }
.cta { font-family: var(--body); margin: 2.5rem 0 0; padding: 1.5rem; border: 2px solid var(--ink); border-radius: var(--radius-m); background: var(--sheet); }
.cta p { margin-bottom: 0.9rem; }
.cta a { display: inline-block; background: var(--flash); color: #fff; padding: 0.6rem 1.1rem; border-radius: var(--radius-s); text-decoration: none; font-weight: 600; }
.cta a:hover { background: var(--flash-dark); }

/* Responsive */
@media (max-width: 1180px) {
  .studio { grid-template-columns: minmax(230px, 270px) minmax(0, 1fr); grid-template-areas: "add stage" "side side"; }
  .panel-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .side-block { border-bottom: 0; border-right: 1px solid var(--rule); }
}
@media (max-width: 760px) {
  .studio { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "add" "side"; }
  .panel-add { position: static; max-height: none; }
  .motif-grid { grid-template-columns: repeat(5, 1fr); }
  .stage-frame { min-width: 0; padding: 8px; }
  .content-split { grid-template-columns: 1fr; }
  .side-block { border-right: 0; border-bottom: 1px solid var(--rule); }
  body { font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* Ad slots: space is reserved up front so loading ads doesn't shift the page. */
.ad-slot { max-width: 1100px; margin: 3rem auto 0; padding: 0 clamp(1rem, 3vw, 2rem); min-height: 280px; }
.ad-slot::before { content: "Advertisement"; display: block; font-size: 0.75rem; color: var(--ink-soft); margin-bottom: 0.35rem; }
.ad-slot--off { display: none; }
.ad-slot--preview { display: grid; }
.ad-slot--preview::after { content: "Ad slot " attr(data-ad-slot); display: grid; place-items: center; min-height: 250px; border: 2px dashed var(--rule); border-radius: var(--radius-m); color: var(--ink-soft); font-size: 0.875rem; }
.article .ad-slot { padding: 0; margin: 2.5rem 0; font-family: var(--body); }
@media (max-width: 760px) { .ad-slot { min-height: 300px; } }

/* Ideas, meanings and lettering tools */
.ideas { list-style: none; padding: 0; margin: 1.25rem 0 2rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1.25rem; font-family: var(--body); font-size: 0.95rem; line-height: 1.5; }
.idea img { width: 100%; height: auto; aspect-ratio: 1; border-radius: var(--radius-m); margin-bottom: 0.6rem; }
.idea h3 { font-size: 1.05rem; margin-bottom: 0.25rem; }
.idea h3 a { color: var(--ink); }
.idea p { color: var(--ink-soft); margin-bottom: 0.4rem; }
.idea > a { font-weight: 600; }
.meanings { list-style: none; padding: 0; margin: 1rem 0 2rem; display: grid; gap: 1.25rem; }
.meanings li { display: grid; grid-template-columns: 96px 1fr; gap: 1rem; align-items: start; scroll-margin-top: 1rem; }
.meanings img { border-radius: var(--radius-s); }
.meanings h3 { margin-bottom: 0.2rem; }
.meanings p { margin-bottom: 0.3rem; }
.meanings a { font-family: var(--body); font-size: 0.95rem; font-weight: 600; }
.tool-box { font-family: var(--body); margin: 1.5rem 0 2rem; }
.gen-input { font: inherit; font-size: 1.125rem; width: 100%; padding: 0.65rem 0.8rem; border: 2px solid var(--ink); border-radius: var(--radius-m); background: var(--sheet); color: var(--ink); }
.font-cards { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem; }
.font-card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 1.1rem 1.1rem 0.9rem; }
.font-sample { font-size: clamp(1.9rem, 5vw, 2.5rem); line-height: 1.3; margin: 0 0 0.6rem; min-height: 1.3em; overflow-wrap: anywhere; color: #000; }
.font-meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--ink-soft); }
.roman { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 1.25rem; }
.roman-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 0.75rem; }
.roman-out { font-family: 'Bebas Neue', var(--body); font-size: clamp(2rem, 6vw, 3rem); letter-spacing: 0.08em; color: #000; margin: 0.25rem 0 1rem; overflow-wrap: anywhere; }
.roman-btn { width: auto; }

/* Font generator groups */
.font-jump ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1.25rem 0 0; padding: 0; }
.font-jump a { display: inline-block; padding: 0.35rem 0.75rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--sheet); text-decoration: none; font-size: 0.9rem; color: var(--ink); }
.font-jump a:hover { border-color: var(--violet); color: var(--violet); }
.font-group { margin-top: 2.5rem; scroll-margin-top: 1rem; }
.font-group > h2 { margin-bottom: 0.2em; }
.font-group > p { color: var(--ink-soft); margin: 0; max-width: 62ch; }
.font-name { font-family: var(--body); font-size: 0.9rem; font-weight: 500; color: var(--ink-soft); margin: 0; }
.gen .ad-slot { padding: 0; margin-top: 3.5rem; }
.gen { max-width: 1100px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2rem) 0; }
.gen .lede { margin-bottom: 1.5rem; }
