/* ==============================
   CSS Variables for Color Scheme
   ============================== */
:root {
  /* Light neutral background */
  --bg-light: #FDF9F6;

  /* Primary reds drawn from the kimono */
  --red-primary: #DD3012;
  --red-secondary: #AA1400;

  /* Deep charcoal/black accent */
  --charcoal: #0A0A00;

  /* Text color (dark neutral) */
  --text-dark: #111111;

  /* Navigation bar height */
  --nav-height: 100px;
}

/* ==============================
   Reset + Base
   ============================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  min-height: 100%;
  height: auto;
}

body {
  color: var(--text-dark);
  background: var(--bg-light);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100%;
  height: auto;
  overflow-x: hidden;
}

/* ==============================
   Global Typography
   ============================== */
p {
  font-size: 1rem;
  margin-bottom: 1rem;
  line-height: 1.6;
  color: var(--text-dark);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-weight: bold;
  color: var(--charcoal);
  line-height: 1.3;
  margin-bottom: 1rem;
}

h1 { font-size: 3rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

a {
  text-decoration: none;
  color: inherit;
}

/* ==============================
   Frame-Based App Layout
   ============================== */
html, body {
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-light);
}

/* ==============================
   Top Navigation
   ============================== */
.top-nav {
  height: 70px;
  background: var(--bg-light);
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 100;
  flex-shrink: 0;
}

.top-nav .logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
}

.top-nav .logo img {
  width: 45px;
  height: 45px;
  border-radius: 50%;
}

.top-nav .logo span {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--charcoal);
}

.top-nav .nav-pills {
  display: flex;
  gap: 0.75rem;
}

.top-nav .nav-pills button {
  padding: 0.6rem 1.2rem;
  background: transparent;
  color: var(--charcoal);
  border: 2px solid transparent;
  border-radius: 25px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.top-nav .nav-pills button.active {
  background: var(--red-primary);
  color: white;
  border-color: var(--red-primary);
}

.top-nav .nav-pills button:hover:not(.active) {
  border-color: var(--red-primary);
  color: var(--red-primary);
}

/* ==============================
   Central Content Frame
   ============================== */
.content-frame {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: white;
}

.content-panel {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem;
  background: white;
  -webkit-overflow-scrolling: touch;
}

.content-panel.active {
  opacity: 1;
  visibility: visible;
}

.content-panel-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: white;
}

/* ==============================
   Bottom Navigation
   ============================== */
.bottom-nav {
  height: 70px;
  background: var(--charcoal);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  flex-shrink: 0;
}

.bottom-nav button {
  padding: 0.6rem 1.2rem;
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.bottom-nav button:hover {
  background: var(--red-primary);
  border-color: var(--red-primary);
}

.bottom-nav button.active {
  background: var(--red-primary);
  border-color: var(--red-primary);
}

.bottom-nav .divider {
  color: rgba(255,255,255,0.3);
  font-weight: 300;
}

/* ==============================
   Home Section (with kiri.jpg)
   ============================== */
.home-container {
  display: flex;
  align-items: center;
  gap: 3rem;
  height: 100%;
  background: white;
}

.home-image {
  flex: 0 0 400px;
}

.home-image img {
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.home-text {
  flex: 1;
}

.home-text h2 {
  font-size: 2rem;
  color: var(--charcoal);
  margin-bottom: 1rem;
}

.home-text p {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 0.8rem;
  color: var(--text-dark);
}

/* ==============================
   About Section
   ============================== */
.about-container {
  display: flex;
  align-items: center;
  gap: 3rem;
  height: 100%;
  background: white;
}

.about-image {
  flex: 0 0 400px;
}

.about-image img {
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.about-text {
  flex: 1;
}

.about-text h2 {
  font-size: 2rem;
  color: var(--charcoal);
  margin-bottom: 1rem;
}

.about-text p {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 0.8rem;
  color: var(--text-dark);
}

/* ==============================
   Services Grid
   ============================== */
.services-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  height: 100%;
  align-content: center;
  background: white;
}

.service-card {
  text-align: center;
  padding: 1rem;
  border: 1px solid var(--charcoal);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.service-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(221,48,18,0.2);
  border-color: var(--red-primary);
}

.service-card img {
  width: 40px;
  height: 40px;
  margin-bottom: 0.5rem;
}

.service-card h3 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--charcoal);
}

.service-card p {
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--text-dark);
}

/* ==============================
   Service Modal
   ============================== */
.service-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.service-modal.active {
  display: flex;
}

.service-modal-content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  position: relative;
}

.service-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #666;
}

.service-modal-close:hover {
  color: var(--red-primary);
}

.service-modal h3 {
  color: var(--red-primary);
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.service-modal p {
  line-height: 1.6;
  color: #333;
}

/* ==============================
   Contact Panel & Form
   ============================== */
.contact-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: white;
}

.contact-form {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  position: relative;
}

.contact-form .close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
}

.contact-form .close:hover {
  color: var(--red-primary);
}

.contact-form h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--charcoal);
  text-align: center;
}

.contact-form label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--charcoal);
}

.contact-form input,
.contact-form textarea,
.contact-form select {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
}

.contact-form select {
  font-size: 1rem;
  background-color: #fff;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'><path fill='%23666' d='m0 0 2 3 2-3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 0.65rem auto;
}

.contact-form select:focus {
  outline: none;
  border-color: var(--red-primary);
}

.contact-form select:required:invalid {
  color: #999;
}

.contact-form button[type="submit"] {
  width: 100%;
  padding: 0.75rem;
  background: var(--red-primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s;
}

.contact-form button[type="submit"]:hover {
  background: var(--red-secondary);
}

/* Form feedback */
.form-feedback {
  padding: 16px;
  border-radius: 8px;
  text-align: center;
  margin: 8px 0;
}

.form-success {
  background: #f0fff4;
}

.form-error {
  background: #fff5f5;
}

.form-body[hidden] {
  display: none !important;
}

.form-success h4 {
  margin: 0 0 6px;
}

.form-success .success-close {
  margin-top: 10px;
  padding: 0.5rem 1rem;
  background: var(--red-primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.form-success .success-close:hover {
  background: var(--red-secondary);
}

/* ==============================
   Text Panels (Privacy, Articles)
   ============================== */
.text-panel {
  overflow-y: auto;
  padding: 2rem;
  background: white;
}

.text-panel .policy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: white;
  z-index: 1;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
  margin-bottom: 1rem;
}

/* Privacy panel needs sticky header for long text */
#panel-privacy .policy-header {
  position: sticky;
  top: 0;
  background: white;
}

.text-panel .policy-header h2 {
  color: var(--red-primary);
  margin-bottom: 0;
}

.text-panel .policy-header .close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
}

.text-panel .policy-header .close:hover {
  color: var(--red-primary);
}

.text-panel .policy-body {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: white;
}

.text-panel pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid #eee;
}

.policy-loading {
  padding: 2rem;
  text-align: center;
  color: #666;
}

.policy-error {
  background: #ffeaea;
  color: #d32f2f;
  padding: 15px;
  margin: 1rem;
  border-radius: 4px;
  border: 1px solid #ffcdd2;
  text-align: center;
}

#privacy-content,
#articles-content {
  line-height: 1.7;
  background: white;
}

/* ==============================
   Articles Section Styles
   ============================== */
.articles-section {
  padding: 2rem 0;
  background: white;
}

.articles-section header {
  text-align: center;
  margin-bottom: 3rem;
  background: white;
}

.articles-title {
  font-size: 2.5rem;
  color: var(--charcoal);
  margin-bottom: 1rem;
}

.articles-intro {
  font-size: 1.1rem;
  color: var(--text-dark);
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.6;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
  background: white;
}

.article-card {
  background: white;
  border: 1px solid var(--charcoal);
  border-radius: 8px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.article-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  border-color: var(--red-primary);
}

.article-card h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  line-height: 1.4;
}

.article-card h2 a {
  color: var(--charcoal);
  text-decoration: none;
  transition: color 0.2s;
}

.article-card h2 a:hover {
  color: var(--red-primary);
}

.article-excerpt {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-dark);
  margin-bottom: 1rem;
  flex-grow: 1;
}

.article-meta {
  font-size: 0.85rem;
  color: #666;
  padding-top: 1rem;
  border-top: 1px solid #eee;
  margin-top: auto;
}

/* Override for articles loaded in panel */
#articles-content .articles-section {
  padding: 0;
  background: white;
}

#articles-content {
  background: white;
}

#articles-content h1,
#articles-content h2,
#articles-content h3 {
  color: inherit;
}

/* ==============================
   FAQ Panel
   ============================== */
#panel-faq {
  padding: 0;
  overflow: hidden;
  background: white;
}

#panel-faq .close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

#panel-faq .close:hover {
  background: rgba(0,0,0,0.7);
}

#faq-content {
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: white;
}

#faq-content iframe {
  width: 100%;
  min-height: 600px;
  height: 100%;
  border: none;
  display: block;
  background: white;
}

/* ==============================
   Notice Bar
   ============================== */
.notice {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 6px;
  background: #f0fff4;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  font-size: 14px;
  z-index: 9999;
}

.notice.error {
  background: #fff5f5;
}

/* ==============================
   Responsive Adjustments
   ============================== */
@media (max-width: 768px) {
  .top-nav {
    padding: 0 1rem;
  }

  .top-nav .logo span {
    display: none;
  }

  .top-nav .nav-pills button {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
  }

  .bottom-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    padding: 0.4rem;
    gap: 0.4rem;
    width: 100%;
  }

  .bottom-nav .divider {
    display: none;
  }

  .bottom-nav button {
    padding: 0.5rem 0.4rem;
    font-size: 0.75rem;
    white-space: normal;
    line-height: 1.2;
    text-align: center;
    width: 100%;
  }

  .bottom-nav button:nth-child(9) {
    grid-column: 1 / -1;
  }

  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .home-container,
  .about-container {
    flex-direction: column;
  }

  .home-image,
  .about-image {
    flex: none;
    width: 100%;
    max-width: 300px;
  }

  .content-panel {
    padding: 1rem;
  }

  .articles-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .articles-title {
    font-size: 2rem;
  }
  
  .articles-intro {
    font-size: 1rem;
  }
}