/* ============================================================
   japancalc.com — Design System CSS
   Version: 1.0.0
   Generated from PRD v1.0 + Tech Spec v1.0
   ============================================================ */

/* ============================================================
   1. Design Tokens (CSS Custom Properties)
   ============================================================ */
:root {
  /* Colors */
  --color-primary:    #1A3A5C;
  --color-accent:     #0B6E5F;
  --color-bg:         #FFFFFF;
  --color-bg-alt:     #F8F9FA;
  --color-text:       #1A1A1A;
  --color-text-muted: #6B7280;
  --color-border:     #E5E7EB;
  --color-success:    #065F46;
  --color-warning:    #92400E;
  --color-error:      #DC2626;
  --color-focus:      rgba(11, 110, 95, 0.15);

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --font-size-base: 16px;
  --line-height:     1.6;

  /* Spacing & Layout */
  --radius:        8px;
  --radius-lg:     12px;
  --shadow-sm:     0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-md:     0 4px 12px rgba(0, 0, 0, 0.10);
  --max-width:     1100px;
  --content-width: 680px;
  --sidebar-width: 220px;
  --gap:           40px;
  --spacing:       1rem;
  --nav-height:    56px;

  /* Breakpoint reference (used in media queries):
     Mobile:  < 768px
     Tablet:  768px – 1024px
     Desktop: > 1024px
  */
}

/* ============================================================
   2. Reset
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

img, svg {
  display: block;
  max-width: 100%;
}

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

table {
  border-collapse: collapse;
  width: 100%;
}

/* ============================================================
   3. Typography
   ============================================================ */
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  line-height: 1.3;
  font-weight: 700;
}

h1 {
  font-size: 1.75rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.375rem;
  color: var(--color-accent);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1.125rem;
  color: var(--color-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

h4 {
  font-size: 1rem;
  color: var(--color-text);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-bg-alt);
  padding: 0.125em 0.375em;
  border-radius: 4px;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.tool-subtitle {
  font-size: 1rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.tool-desc {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

/* ============================================================
   4. Page Layout
   ============================================================ */
.site-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

.page-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

@media (min-width: 1025px) {
  .page-layout {
    grid-template-columns: 1fr 200px;
  }
}

.content {
  min-width: 0;
}

.sidebar {
  display: none;
}

@media (min-width: 1025px) {
  .sidebar {
    display: block;
  }
}

/* ============================================================
   5. Navigation
   ============================================================ */
.site-nav {
  background: var(--color-primary);
  color: #FFFFFF;
  padding: 0 1rem;
}

.site-nav .nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.site-nav .nav-logo {
  font-size: 1.125rem;
  font-weight: 700;
  color: #FFFFFF;
  text-decoration: none;
}

.site-nav .nav-links {
  display: none;
  list-style: none;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .site-nav .nav-links {
    display: flex;
  }
}

.site-nav .nav-links a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.site-nav .nav-links a:hover,
.site-nav .nav-links a[aria-current="page"] {
  color: #FFFFFF;
}

.nav-lang-toggle {
  font-size: 0.8125rem;
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}

.nav-lang-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
}

.nav-hamburger {
  display: flex;
  background: none;
  border: none;
  color: #FFFFFF;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

@media (min-width: 768px) {
  .nav-hamburger {
    display: none;
  }
}

/* Mobile menu */
.nav-mobile-menu {
  display: none;
  flex-direction: column;
  background: var(--color-primary);
  padding: 0.5rem 1rem 1rem;
}

.nav-mobile-menu.is-open {
  display: flex;
}

.nav-mobile-menu a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 0.5rem 0;
  font-size: 0.9375rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  padding: 0.75rem 1rem;
  max-width: var(--max-width);
  margin: 0 auto;
}

.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0;
  margin: 0;
}

.breadcrumb li::after {
  content: "›";
  margin-left: 0.375rem;
  color: var(--color-border);
}

.breadcrumb li:last-child::after {
  content: "";
}

.breadcrumb a {
  color: var(--color-text-muted);
}

.breadcrumb a:hover {
  color: var(--color-accent);
}

/* Back to top */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  z-index: 100;
}

.back-to-top.is-visible {
  display: flex;
}

/* ============================================================
   6. Tool Interface
   ============================================================ */
.tool-box {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* Tabs */
.tool-tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 1.5rem;
  gap: 0;
}

.tool-tab {
  padding: 0.625rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tool-tab:hover {
  color: var(--color-text);
}

.tool-tab[aria-selected="true"],
.tool-tab.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.tool-tab-panel {
  display: none;
}

.tool-tab-panel.is-active {
  display: block;
}

/* Input fields */
.field-group {
  margin-bottom: 1rem;
}

.field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.field-input,
.field-select {
  width: 100%;
  height: 44px;
  padding: 0 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input:focus,
.field-select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(11, 110, 95, 0.15);
}

.field-input.is-error,
.field-select.is-error {
  border-color: var(--color-error);
}

.field-error {
  font-size: 0.8125rem;
  color: var(--color-error);
  margin-top: 0.25rem;
}

/* Input field alias (spec name) */
.input-field {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-appearance: none;
}

.input-field:focus {
  outline: none;
  border: 2px solid var(--color-accent);
}

.input-field.error {
  border-color: var(--color-error);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 44px;
  padding: 0 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--color-primary);
  color: #FFFFFF;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-accent {
  background: var(--color-accent);
  color: #FFFFFF;
}

.btn-accent:hover {
  opacity: 0.9;
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

.btn-outline:hover {
  background: var(--color-bg-alt);
}

.btn-sm {
  height: 32px;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
}

/* Result box */
.result-box {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1rem;
  position: relative;
}

.result-primary {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-accent);
  font-family: var(--font-mono);
}

.result-secondary {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

@media (max-width: 767px) {
  .result-grid {
    grid-template-columns: 1fr;
  }
}

.result-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.copy-feedback {
  font-size: 0.8125rem;
  color: var(--color-success);
  font-weight: 600;
}

/* Keyword / tag chips */
.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.chip {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.chip-kd {
  background: var(--color-primary);
  color: #FFFFFF;
  border-color: var(--color-primary);
}

/* ============================================================
   7. Ad Zones
   ============================================================ */
.ad-zone {
  text-align: center;
  overflow: hidden;
}

.ad-zone-atf {
  min-height: 90px;
  margin-bottom: 1rem;
}

.ad-zone-sidebar {
  min-height: 600px;
  position: sticky;
  top: 1rem;
}

.ad-zone-btf {
  min-height: 250px;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.ad-zone-related {
  min-height: 250px;
  margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
  .ad-zone-sidebar {
    display: none;
  }
}

/* Ad zone aliases (spec names) */
.ad-atf {
  min-height: 90px;
  margin: 0 auto 1rem;
}

.ad-btf {
  min-height: 250px;
  margin: 1.5rem auto;
}

.ad-sidebar-zone {
  min-height: 600px;
  position: sticky;
  top: 1rem;
}

.ad-related {
  min-height: 250px;
  margin: 1rem auto;
}

@media (max-width: 1024px) {
  .ad-sidebar-zone {
    display: none;
  }
}

/* ============================================================
   8. Quick Reference Tables
   ============================================================ */
.ref-table {
  margin: 1.5rem 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ref-table table {
  width: 100%;
}

.ref-table th,
.ref-table td {
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--color-border);
}

.ref-table th {
  background: var(--color-primary);
  color: #FFFFFF;
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.ref-table tr:nth-child(even) td {
  background: var(--color-bg-alt);
}

.ref-table tr:last-child td {
  border-bottom: none;
}

@media (max-width: 767px) {
  .ref-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================================
   9. Cards
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.tool-card {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--color-text);
  transition: box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tool-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--color-accent);
  text-decoration: none;
}

.tool-card-icon {
  font-size: 1.5rem;
}

.tool-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
}

.tool-card-subtitle {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.badge-upcoming {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--color-warning);
  color: #FFFFFF;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Related tools grid */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.related-card {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: border-color 0.15s;
}

.related-card:hover {
  border-color: var(--color-accent);
  text-decoration: none;
}

/* ============================================================
   10. FAQ
   ============================================================ */
.faq-section {
  margin: 2rem 0;
}

.faq-item {
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 0;
}

.faq-item:first-child {
  border-top: 1px solid var(--color-border);
}

.faq-q {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 0;
}

.faq-q::after {
  content: "+";
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.faq-q[aria-expanded="true"]::after {
  content: "−";
}

.faq-a {
  font-size: 0.9375rem;
  color: var(--color-text);
  line-height: 1.65;
  padding-top: 0.75rem;
  display: none;
}

.faq-a.is-open {
  display: block;
}

/* ============================================================
   11. Footer
   ============================================================ */
.site-footer {
  background: var(--color-primary);
  color: rgba(255, 255, 255, 0.75);
  padding: 2rem 1rem;
  font-size: 0.8125rem;
  margin-top: 3rem;
}

.site-footer .footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .site-footer .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  list-style: none;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
}

.footer-links a:hover {
  color: #FFFFFF;
}

.footer-attribution {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 0.5rem;
}

/* ============================================================
   12. Utility Classes
   ============================================================ */
.text-center { text-align: center; }
.text-muted  { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error  { color: var(--color-error); }
.text-mono   { font-family: var(--font-mono); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden { display: none !important; }
.visible-desktop { display: none; }
@media (min-width: 1025px) {
  .visible-desktop { display: block; }
}
.visible-mobile { display: block; }
@media (min-width: 768px) {
  .visible-mobile { display: none; }
}

/* ============================================================
   13. Accessibility
   ============================================================ */
.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;
}

[aria-live="polite"] {
  position: relative;
}

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

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--color-primary);
  color: #FFFFFF;
  border-radius: var(--radius);
  font-size: 0.875rem;
  z-index: 1000;
}

.skip-link:focus {
  top: 0.5rem;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
