/* ============================================================
   画像文字起こし+  —  bit-skate WebTools
   Design system: "Skate Narrative" (Minimalist Brutalism)
   ============================================================ */

/* ---- Fonts (self-hosted, latin variable subsets; JP falls back to system) ---- */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('vendor/fonts/space-grotesk.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('vendor/fonts/inter.woff2') format('woff2');
}

/* ---- Tokens ---- */
:root {
  --ink: #111111;          /* primary */
  --ink-2: #333333;        /* secondary text */
  --ink-3: #666666;        /* tertiary / captions */
  --line: #d8d8d8;         /* structural dividers */
  --surface: #ffffff;
  --surface-dim: #f4f3f3;  /* preview backdrop */
  --accent: #d93a2b;       /* the single accent — "+" and progress fill */
  --error: #ba1a1a;

  --jp: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic',
        'Noto Sans JP', 'Meiryo', sans-serif;
  --display: 'Space Grotesk', var(--jp);
  --body: 'Inter', var(--jp);

  --xs: 4px; --sm: 8px; --md: 16px; --lg: 32px; --xl: 64px;
  --gutter: 24px; --margin: 40px;
  --maxw: 1100px;
}

/* ---- Reset-ish ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--surface);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; }

/* Everything sharp — no radii anywhere. */
* { border-radius: 0 !important; }

/* ---- Label style (label-caps) ---- */
.label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1;
}

/* ---- Header ---- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px var(--margin);
  border-bottom: 2px solid var(--ink);
}
.site-header .brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  text-decoration: none;
}
.site-header .back {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ink);
  text-decoration: none;
}
.site-header .back:hover { color: var(--accent); }

/* ---- Shell ---- */
.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--lg) var(--margin) var(--xl);
}

/* ---- Title ---- */
.tool-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 48px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}
.tool-title .plus { color: var(--accent); }

/* ---- Work grid ---- */
.work {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--gutter);
  margin-top: var(--lg);
}
.col-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--sm);
  min-height: 14px;
}
.counter {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

/* ---- Drop zone ---- */
.dropzone {
  position: relative;
  border: 2px solid var(--ink);
  background: var(--surface);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: background 100ms linear, color 100ms linear;
}
.dropzone:hover,
.dropzone:focus-visible {
  background: var(--ink);
  color: var(--surface);
  outline: none;
}
.dropzone:focus-visible { box-shadow: inset 0 0 0 2px var(--surface); }

.dropzone .prompt {
  display: flex;
  flex-direction: column;
  gap: var(--sm);
  align-items: center;
  text-align: center;
  padding: var(--md);
  pointer-events: none;
}
.dropzone .prompt .line {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.dropzone .prompt .line.sub { color: var(--ink-3); }
.dropzone:hover .prompt .line.sub,
.dropzone:focus-visible .prompt .line.sub { color: var(--surface); }

/* preview state */
.dropzone.has-image { cursor: pointer; background: var(--surface-dim); }
.dropzone.has-image:hover { background: var(--surface-dim); color: var(--ink); }
.dropzone .preview {
  width: 100%;
  height: 100%;
  min-height: 300px;
  object-fit: contain;
  display: none;
}
.dropzone.has-image .preview { display: block; }
.dropzone.has-image .prompt { display: none; }

.badge {
  position: absolute;
  top: var(--sm);
  font-family: var(--display);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 3px 6px;
  background: var(--ink);
  color: var(--surface);
  text-transform: uppercase;
}
.badge.re-input { right: var(--sm); display: none; }
.dropzone.has-image .badge.re-input { display: block; }
.badge.resized { right: calc(var(--sm) + 78px); background: var(--accent); display: none; }
.dropzone.has-image.resized .badge.resized { display: block; }

/* ---- Progress bar ---- */
.progress {
  height: 8px;
  background: var(--line);
  margin-top: var(--md);
  overflow: hidden;
  visibility: hidden;
}
.progress.active { visibility: visible; }
.progress .fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 160ms linear;
}

/* privacy caption — above the progress bar */
.privacy {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: var(--md);
}

/* ---- MODE selector ---- */
.mode { margin-top: var(--lg); }
.mode .label { display: block; margin-bottom: var(--sm); }
.seg {
  display: inline-flex;
  border: 1px solid var(--ink);
}
.seg button {
  font-family: var(--jp);
  font-weight: 700;
  font-size: 13px;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--ink);
  border: none;
  border-left: 1px solid var(--ink);
  cursor: pointer;
  transition: background 100ms linear, color 100ms linear;
}
.seg button:first-child { border-left: none; }
.seg button:hover { background: var(--ink); color: var(--surface); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode .hint {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: var(--sm);
}

/* ---- Result ---- */
.result {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  border: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  padding: 12px 14px;
}
.result:focus { outline: none; border-width: 2px; padding: 11px 13px; }
.result::placeholder { color: var(--ink-3); }

/* ---- Buttons ---- */
.actions {
  display: flex;
  gap: var(--sm);
  margin-top: var(--md);
  flex-wrap: wrap;
}
.btn {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 18px;
  cursor: pointer;
  border: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  transition: background 100ms linear, color 100ms linear;
}
.btn:hover { background: var(--ink); color: var(--surface); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--ink); color: var(--surface); }
.btn.primary:hover { background: var(--ink-2); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn.copied { background: var(--accent); color: var(--surface); border-color: var(--accent); }

/* ---- Error banner ---- */
.error-banner {
  display: none;
  border: 1px solid var(--error);
  color: var(--error);
  padding: 12px 16px;
  margin-top: var(--md);
  font-size: 14px;
}
.error-banner.active { display: block; }
.error-banner .retry {
  margin-left: var(--sm);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--error);
  font: inherit;
}

/* ---- Info note ---- */
.note {
  border: 1px solid var(--line);
  padding: 16px;
  margin-top: var(--xl);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-3);
}
.note .i { font-weight: 700; margin-right: 6px; }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 16px var(--margin);
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  gap: var(--md);
  align-items: center;
}
.site-footer .brand {
  font-family: var(--display);
  font-weight: 700;
  color: var(--ink);
}

/* ---- Drag overlay ---- */
.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 2px var(--ink);
}
body.dragging .drag-overlay { display: flex; }
.drag-overlay span {
  font-family: var(--display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}

/* ---- Screen-reader only ---- */
.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;
}

/* ---- Mobile ---- */
@media (max-width: 960px) {
  .site-header, .site-footer { padding-left: var(--md); padding-right: var(--md); }
  .shell { padding: var(--lg) var(--md) var(--lg); }
  .tool-title { font-size: 32px; }
  .work { grid-template-columns: 1fr; gap: var(--lg); }
  .dropzone { min-height: 220px; }
  .dropzone .preview { min-height: 220px; }
  .result { min-height: 220px; }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1; padding: 12px 8px; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .progress .fill { transition: none !important; }
}
