/* ===================================
   Typography & CSS Reset
   =================================== */

@font-face {
  font-family: "NomNaTong";
  src: url("/Font/NomNaTong-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "NVN January";
  src: url("/Font/NVNJanuary-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "FZ-SG Attic Antique";
  src: url("/Font/FZ-SG Attic Antique (Regular).ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: "FZ-SG Attic Antique", "Arial Unicode MS", Arial, sans-serif;
  background-image: url("/assets/background2.png");
  background-repeat: repeat;
  background-size: 600px;
  background-attachment: fixed;
  color: #000000;
  line-height: 1.4;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.explanation-label,
.keyword-detail,
.keyword-citation,
.poem-output,
.subtitle,
label,
input,
button {
  font-family: "FZ-SG Attic Antique", Arial, sans-serif;
}

.main-title,
.output-title,
.explanation-title,
h4 {
  font-family: "NVN January", serif;
  text-transform: uppercase;
}

/* ===================================
   Main Container (Paper Surface)
   =================================== */

.container {
  position: relative;
  z-index: 2;
  max-width: 1600px; /* Drastic increase to match Figma wide design */
  width: 98%;
  margin: 40px auto;
  padding: 60px 80px 100px; /* Added more bottom padding for footer */
  background-image: url("/assets/background3.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  min-height: 800px;
  display: flex;
  flex-direction: column;
  filter: drop-shadow(0 15px 45px rgba(0, 0, 0, 0.3));
}

.container::before {
  content: "";
  position: absolute;
  /* Soft-Edge Surgical Fill: cover holes while blending naturally */
  top: 10px;
  bottom: 10px;
  left: 10px;
  right: 10px;
  background-color: #f6f0e4;
  filter: blur(10px);
  border-radius: 30px;
  z-index: -1;
  pointer-events: none;
}

/* ===================================
   Title Section
   =================================== */

.title-section {
  text-align: center;
  margin-bottom: 60px;
  padding-top: 20px;
}

.main-title {
  font-size: 42px;
  font-weight: 900;
  color: #000000;
  margin-bottom: 15px;
  letter-spacing: 0px;
  line-height: 1.1;
}

.subtitle {
  font-size: 16px;
  color: #333333;
  font-weight: normal;
  max-width: 1200px; /* Increased to match wider layout */
  margin: 0 auto;
  line-height: 1.4;
}

/* ===================================
   Form Container
   =================================== */

.form-container {
  background: transparent;
  border-radius: 12px;
  padding: 40px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  width: 100%; /* Force full width expansion */
  max-width: 100%;
  margin: 0 auto 40px;
}

/* ===================================
   Form Elements
   =================================== */

.form-group {
  margin-bottom: 25px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: bold;
  color: #000000;
  margin-bottom: 10px;
}

.form-group input[type="text"] {
  width: 100%;
  padding: 10px 15px;
  font-size: 13px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
  color: #000000;
}

.form-group input[type="text"]:focus {
  outline: none;
  border-color: #000;
}

.form-group input[type="text"]::placeholder {
  color: #999999;
  font-style: normal;
  opacity: 0.6;
}

/* ===================================
   Submit Button
   =================================== */

.submit-btn {
  width: 100%;
  padding: 14px 24px;
  font-size: 13px;
  font-weight: normal;
  color: #ffffff;
  background-color: #000000;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 10px;
  letter-spacing: 0.5px;
}

.submit-btn:hover {
  background-color: #333333;
}

.submit-btn:active {
  transform: scale(0.98);
}

.submit-btn:disabled {
  background-color: #999999;
  cursor: not-allowed;
}

/* Button Loading State */
.btn-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Spinner Animation */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===================================
   Error Message
   =================================== */

.error-message {
  margin-top: 20px;
  padding: 15px;
  background-color: #ffebee;
  border-left: 4px solid #c62828;
  border-radius: 4px;
  color: #c62828;
  font-size: 14px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===================================
   Output Section
   =================================== */

.output-section {
  max-width: 100%;
  margin: 20px auto 0;
}

.poem-container {
  background: transparent;
  padding: 0;
  box-shadow: none;
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  padding: 40px;
  width: 100%; /* Force full width expansion */
}

.output-title {
  font-size: 20px;
  font-weight: bold;
  color: #000000;
  margin-bottom: 20px;
  text-align: left;
  border-bottom: none;
  padding-bottom: 0;
}

.poem-output {
  font-size: 15px;
  line-height: 1.5;
  color: #000000;
  white-space: pre-wrap;
  word-wrap: break-word;
  text-align: left;
  margin-bottom: 25px;
  padding: 0;
  background-color: transparent;
}

/* ===================================
   Keywords Section & Explanation
   =================================== */

.poem-separator {
  width: 100%;
  height: 0.5px;
  background-color: rgba(0, 0, 0, 0.4);
  margin: 25px 0;
}

.explanation-section {
  margin-top: 25px;
  border-top: none;
  padding-top: 0;
}

.explanation-title {
  font-size: 20px;
  font-weight: bold;
  color: #000000;
  text-align: left;
  margin-bottom: 15px;
}
.explanation-label {
  font-weight: normal;
  color: #000;
  opacity: 1;
}
.keyword-detail,
.keyword-citation {
  opacity: 0.7;
}

.keyword-item {
  margin-bottom: 15px;
  padding: 0;
  background-color: transparent;
  border: none;
}

.keyword-item h4 {
  font-size: 14px;
  font-weight: bold;
  color: #000000;
  margin-bottom: 10px;
}

.keyword-detail {
  margin-bottom: 8px;
  line-height: 1.4;
  font-size: 13px;
  color: #333333;
}

.keyword-detail strong {
  color: #000;
  font-weight: bold;
  opacity: 1;
}

.keyword-citation {
  margin-top: 10px;
  margin-left: 0;
  padding-left: 0;
  border-left: none;
  color: #000;
  font-size: 13px;
  line-height: 1.4;
}

.keywords-section {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;
  display: none;
}

.keywords-section h3 {
  font-size: 16px;
  color: #666666;
  margin-bottom: 12px;
  font-weight: 600;
}

.keywords-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.keyword-tag {
  display: inline-block;
  padding: 6px 14px;
  background-color: #f5f5f5;
  color: #333333;
  border-radius: 20px;
  font-size: 14px;
  border: 1px solid #e0e0e0;
}

/* ===================================
   Responsive Design
   =================================== */

@media (max-width: 768px) {
  .cloud-pattern {
    height: 250px;
  }

  .container {
    padding: 40px 15px 30px;
  }

  .title-section {
    margin-top: 170px;
    margin-bottom: 40px;
  }

  .main-title {
    font-size: 32px;
  }

  .subtitle {
    font-size: 14px;
  }

  .form-container {
    padding: 35px 30px 40px;
    border-radius: 16px;
  }

  .form-group {
    margin-bottom: 24px;
  }

  .poem-container {
    padding: 35px 30px 40px;
    border-radius: 16px;
  }

  .output-title {
    font-size: 24px;
    margin-bottom: 28px;
    padding-bottom: 20px;
  }

  .poem-output {
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 28px;
  }

  .explanation-title {
    font-size: 18px;
    margin-bottom: 24px;
  }

  .keyword-item {
    padding: 16px;
    margin-bottom: 20px;
  }

  .keyword-item h4 {
    font-size: 15px;
  }

  .keyword-detail {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .main-title {
    font-size: 24px;
  }

  .subtitle {
    font-size: 13px;
  }

  .form-container {
    padding: 25px 20px;
  }

  .poem-container {
    padding: 25px 20px 30px;
  }

  .output-title {
    font-size: 20px;
    margin-bottom: 24px;
    padding-bottom: 18px;
  }

  .poem-output {
    font-size: 15px;
    line-height: 1.75;
  }

  .explanation-title {
    font-size: 17px;
    margin-bottom: 20px;
  }

  .keyword-item {
    padding: 14px;
    margin-bottom: 16px;
  }

  .keyword-item h4 {
    font-size: 14px;
  }

  .keyword-detail {
    font-size: 13px;
  }
}

/* ===================================
   Footer Styles (Paper Aligned)
   =================================== */

.footer {
  margin-top: 20px;
  padding: 40px 0 60px;
  text-align: center;
  width: 100%;
  z-index: 3;
}

.footer-copyright {
  font-size: 14px;
  color: #000;
  font-weight: bold;
  letter-spacing: 0.5px;
}

/* ===================================
   Accessibility Improvements
   =================================== */

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid #000000;
  outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.weight-value {
  font-weight: bold;
  color: #000;
  margin-left: 8px;
}

.slider-container {
  position: relative;
  width: 100%;
  padding: 10px 0 30px;
}

.aesthetic-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.5px;
  background: rgba(0, 0, 0, 0.4);
  outline: none;
  cursor: pointer;
}

.aesthetic-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #000000;
  cursor: pointer;
  border: none;
}

.aesthetic-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #000000;
  cursor: pointer;
  border: none;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 15px;
  padding: 0 4px;
}

.slider-label {
  font-size: 9px;
  color: #333;
  position: relative;
  width: 10px;
  text-align: center;
}

.slider-label::before {
  content: "";
  position: absolute;
  top: -15px;
  left: 50%;
  width: 0.5px;
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
}

.keyword-citation {
  white-space: pre-wrap;
  line-height: 2.2;
  margin-top: 10px;
  display: block;
}

.output-section {
  position: relative; /* For cloud positioning */
}

/* ===================================
   Print Button
   =================================== */
.print-btn {
  display: block;
  margin: 30px auto 0;
  padding: 12px 30px;
  background-color: transparent;
  border: 1px solid #000;
  color: #000;
  border-radius: 50px;
  cursor: pointer;
  font-family: "Arial Unicode MS", Arial, sans-serif;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.3s ease;
}

.print-btn:hover {
  background-color: #000;
  color: #fff;
}

/* ===================================
   Print Styles
   =================================== */
@media print {
  @page {
    size: 76mm 130mm;
    margin: 1.5mm; /* Ultra tight margins */
  }

  .title-section,
  .form-container,
  .footer,
  .cloud-pattern,
  .cloud-side,
  .print-btn {
    display: none !important;
  }

  body {
    background-color: #fff !important;
    background-image: none !important;
    padding: 0;
    margin: 0;
    font-size: 6pt;
    color: #000;
    line-height: 1.1;
    overflow: hidden; /* Prevent overflow */
  }

  /* CRITICAL FIX: Hide the paper edge fill and background images */
  .container::before {
    display: none !important;
  }

  .container {
    padding: 0;
    margin: 0;
    max-width: 100%;
    width: 100%;
    background: none !important;
    min-height: auto !important; /* Reset min-height */
    filter: none !important; /* Remove drop shadows */
    border: none !important;
  }

  .output-section {
    margin: 0;
    padding: 0;
    animation: none;
    max-width: 100%;
  }

  .poem-container {
    box-shadow: none;
    border: none;
    padding: 0.5mm;
    margin: 0;
  }

  .output-title {
    margin-top: 0;
    font-size: 7.5pt;
    margin-bottom: 1mm;
    padding-bottom: 0.5mm;
    border-bottom: 0.5px solid #000;
  }

  .poem-output {
    font-size: 6pt;
    line-height: 1.15;
    margin-bottom: 1.5mm;
    text-align: justify;
  }

  .poem-separator {
    margin: 1mm auto;
    background-color: #000;
    height: 0.5px;
    width: 25%;
  }

  .explanation-section {
    margin-top: 1.5mm;
    padding-top: 1mm;
    border-top: 0.5px solid #000;
    page-break-inside: avoid;
  }

  .explanation-title {
    font-size: 7pt;
    margin-bottom: 1mm;
  }

  .keyword-item {
    padding: 1px;
    margin-bottom: 1mm;
    background-color: transparent;
    border: 0.5px solid #000;
    border-radius: 1px;
    page-break-inside: avoid;
  }

  .keyword-item h4 {
    font-size: 6.5pt;
    margin-bottom: 0.5mm;
  }

  .keyword-detail {
    font-size: 5.5pt;
    margin-bottom: 0.3mm;
    line-height: 1.1;
  }

  .keyword-citation {
    font-size: 6pt;
    line-height: 1.15;
    margin-top: 1mm;
    border-left: 1px solid #000;
    padding-left: 1mm;
    font-style: normal;
  }
}
