/* ============================================================
   Kaze (風) Design System — Reset & Base Styles
   Modern CSS reset + Japanese-optimized base typography
   ============================================================ */

/* ── Modern Reset ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  hanging-punctuation: first allow-end last;
  tab-size: 4;
  line-height: var(--line-height-normal);
  font-size: var(--font-size-base);
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--color-fg);
  background-color: var(--color-bg);
  min-height: 100dvh;
}

/* ── Elements ────────────────────────────────────────────── */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
  overflow-wrap: break-word;
}

p {
  overflow-wrap: break-word;
}

/* Remove inner padding and border in Firefox */
::-moz-focus-inner {
  border-style: none;
  padding: 0;
}

/* Remove outline for non-keyboard focus */
:focus:not(:focus-visible) {
  outline: none;
}

/* Focus visible */
:focus-visible {
  outline: var(--ring-width) solid var(--ring-color);
  outline-offset: var(--ring-offset);
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

[data-theme="dark"] * {
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* ── Selection ───────────────────────────────────────────── */
::selection {
  background-color: var(--zinc-200);
  color: var(--zinc-900);
}

[data-theme="dark"] ::selection {
  background-color: var(--zinc-700);
  color: var(--zinc-100);
}

/* ── Dark Theme Fallback (JS-disabled) ────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
  }

  :root:not([data-theme="light"]) ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
  }

  :root:not([data-theme="light"]) * {
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
  }

  :root:not([data-theme="light"]) ::selection {
    background-color: var(--zinc-700);
    color: var(--zinc-100);
  }
}
