/* ============================================================
   japancalc.com — Design System CSS
   Version: 1.0.0
   Spec:    PRD v1.0 Section 9 + Tech Spec v1.0 Section 9.1
   ============================================================ */

/* ------------------------------------------------------------
   1. Design Tokens
   ------------------------------------------------------------ */
:root {
  --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;
  --font-sans:        "Inter", system-ui, -apple-system, sans-serif;
  --font-mono:        "JetBrains Mono", "Fira Code", monospace;
  --radius:           8px;
  --shadow:           0 1px 3px rgba(0, 0, 0, 0.12);
  --max-width:        1100px;
}

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

body {
  margin: 0;
  padding: 0;
}

img {
  max-width: 100%;
  height: auto;
}

/* ------------------------------------------------------------
   3. Typography
   ------------------------------------------------------------ */
body {
  font-family: var(--font-sans);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
  background: var(--color-bg);
}

h1 {
  font-size: 2rem;
  color: var(--color-primary);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.375rem;
  color: var(--color-accent);
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}

h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
}

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

a:hover {
  text-decoration: none;
}

code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-bg-alt);
  padding: 0.1em 0.3em;
  border-radius: 4px;
}

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

.page-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

.content {
  min-width: 0;
}

.sidebar {
  display: none;
}

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

  .sidebar {
    display: block;
  }
}

/* ------------------------------------------------------------
   5. Navigation
   ------------------------------------------------------------ */
nav.site-nav {
  background: var(--color-primary);
  color: white;
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  color: white;
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
}

.nav-logo:hover {
  color: white;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

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

.nav-links a:hover {
  color: white;
}

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

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

.breadcrumb {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  padding: 0.5rem 1rem;
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
}

.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 0;
}

.breadcrumb li {
  display: flex;
  align-items: center;
}

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

.breadcrumb-sep {
  margin: 0 0.4rem;
  color: var(--color-text-muted);
}

/* Mobile nav */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

.nav-mobile-menu {
  display: none;
}

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

  .nav-hamburger {
    display: block;
  }

  .nav-mobile-menu[aria-hidden="false"] {
    display: block;
    background: var(--color-primary);
    padding: 0.75rem 1rem 1rem;
  }

  .nav-mobile-menu .nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
}

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

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

.tool-desc {
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

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

.tool-tab {
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  background: none;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tool-tab.active,
.tool-tab.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.tool-panel {
  display: none;
}

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

/* Inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.form-input,
.form-select {
  width: 100%;
  height: 44px;
  padding: 0 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: var(--font-sans);
  background: white;
  color: var(--color-text);
  outline: none;
}

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

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

.form-error {
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: 0.3rem;
  display: none;
}

.form-error.visible {
  display: block;
}

/* Result Display */
.result-box {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-top: 1.25rem;
}

.result-box.hidden {
  display: none;
}

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

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

.result-item-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-item-value {
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font-mono);
}

.result-secondary {
  font-size: 0.9rem;
  color: var(--color-text);
}

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

/* Action Buttons */
.btn-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.btn {
  height: 40px;
  padding: 0 1.25rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

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

.btn-primary:hover {
  background: #152e4d;
}

.btn-secondary {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn-secondary:hover {
  background: var(--color-border);
}

.btn-success {
  background: var(--color-success);
  color: white;
}

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

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

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

/* ------------------------------------------------------------
   7. Ad Zones — CLS Prevention
   ------------------------------------------------------------ */
.ad-zone {
  width: 100%;
  overflow: hidden;
  text-align: center;
}

.ad-atf {
  min-height: 90px;
  margin: 0 auto 1rem;
}

.ad-btf {
  min-height: 250px;
  margin: 2rem 0;
}

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

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

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

/* ------------------------------------------------------------
   8. Quick Reference Table
   ------------------------------------------------------------ */
.quick-ref {
  margin: 2rem 0;
}

.quick-ref table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.quick-ref th {
  background: var(--color-primary);
  color: white;
  padding: 0.6rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
}

.quick-ref td {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

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

/* ------------------------------------------------------------
   9. Tool Cards
   ------------------------------------------------------------ */
.tool-card {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--color-text);
  display: block;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}

.tool-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tool-card-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.tool-card-name {
  font-weight: 600;
  color: var(--color-primary);
}

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

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.related-card {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  text-decoration: none;
  color: var(--color-primary);
  font-weight: 500;
  display: block;
  transition: box-shadow 0.15s;
}

.related-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ------------------------------------------------------------
   10. FAQ Section
   ------------------------------------------------------------ */
.faq-list {
  list-style: none;
  margin: 1.5rem 0;
  padding: 0;
}

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

.faq-question {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-answer {
  font-size: 0.9rem;
  color: var(--color-text);
  margin-top: 0.75rem;
  line-height: 1.7;
}

/* ------------------------------------------------------------
   11. Footer
   ------------------------------------------------------------ */
footer.site-footer {
  background: var(--color-primary);
  color: white;
  padding: 2rem 1rem;
  margin-top: 4rem;
  font-size: 0.85rem;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  list-style: none;
  padding: 0;
}

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

.footer-links a:hover {
  color: white;
}

.footer-copy {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
}

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

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

/* ------------------------------------------------------------
   12. Keyword / Tag Chips
   ------------------------------------------------------------ */
.chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  margin: 0.2rem 0.2rem 0.2rem 0;
}

.chip-primary {
  background: #EEF4FF;
  border-color: #C7D7FD;
  color: #1E40AF;
}

/* ------------------------------------------------------------
   13. Utility Classes
   ------------------------------------------------------------ */
.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;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center {
  text-align: center;
}

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

.text-success {
  color: var(--color-success);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.hidden {
  display: none;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: 0.5rem 1rem;
  z-index: 100;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

/* Field error (inline validation) */
.field-error {
  color: var(--color-error);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ------------------------------------------------------------
   14. Responsive Breakpoints
   ------------------------------------------------------------ */
@media (max-width: 768px) {
  h1 {
    font-size: 1.5rem;
  }

  .result-primary {
    font-size: 1.5rem;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .btn-row {
    flex-direction: column;
  }

  .btn-row .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ------------------------------------------------------------
   15. Accessibility — Focus Indicators
   ------------------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

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

.btn:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible,
.tool-tab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
