/* static/css/style.css */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.6;
  color: #333; /* Default text color */
  background-color: #fff; /* Default background */
  font-size: 16px; /* Base font size for mobile */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased; /* Smoother fonts on WebKit */
  -moz-osx-font-smoothing: grayscale; /* Smoother fonts on Firefox */
}

.container {
  width: 100%;
  max-width: 650px; /* Standard content width */
  margin: 0 auto;
  padding: 20px 15px; /* Padding for mobile */
  flex-grow: 1;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 { 
  font-weight: normal; 
  line-height: 1.3; 
  color: #111; /* Darker color for headings */
}
h1 { font-size: 1.5rem; margin-bottom: 0.5em; } /* Base h1, can be overridden */
h2 { font-size: 1.5rem; margin-top: 1em; margin-bottom: 0.5em; } /* Base h2 */
h3 { font-size: 1.25rem; margin-top: 1em; margin-bottom: 0.4em; } /* Base h3 */
p { margin-bottom: 1em; }
a { color: #007bff; text-decoration: none; } /* Standard link color */
a:hover { text-decoration: underline; }

/* --- Header / Logo --- */
.logo-text { 
  font-family: Georgia, serif; 
  font-weight: normal; 
  margin:0; 
  color: #000; 
  font-size: 1.5rem; 
  line-height: 1.2; 
}
a.logo-link { text-decoration: none; display: flex; align-items: center; }
a.logo-link:hover { text-decoration: none; }

/* --- Top Navigation (read.html & bible_home.html) --- */
.top-nav { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  margin-bottom: 1.5em; 
  padding-top: 0; 
  padding-bottom: 0.5em; 
  border-bottom: 1px solid #eee; 
}
.top-nav .logo-text { font-size: 1.5rem; line-height: 1.2; } /* Consistent logo size in nav */
.auth-links { display: flex; align-items: center; position: relative; }
.auth-links .auth-link { 
  font-size: 0.9em; 
  color: #555; 
  text-decoration: none; 
  margin-left: 10px; 
}
.auth-links .auth-link:hover { color: #000; text-decoration: underline; }

/* --- Hamburger Menu Toggle & Small Dropdown --- */
.user-menu-container { position: relative; margin-left: 10px; display: inline-block; vertical-align: middle; }
.hamburger-menu-toggle { background: none; border: none; padding: 8px; margin: 0; cursor: pointer; vertical-align: middle; line-height: normal; width: 40px; height: 38px; /* Match display settings toggle height */ display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.hamburger-icon { display: flex; flex-direction: column; justify-content: space-between; width: 22px; height: 16px; }
.hamburger-icon span { display: block; width: 100%; height: 2px; background-color: #555; border-radius: 1px; transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out, background-color 0.2s ease-in-out; transform-origin: center center; }
.hamburger-menu-toggle.is-active .hamburger-icon span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-menu-toggle.is-active .hamburger-icon span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-menu-toggle.is-active .hamburger-icon span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.hamburger-menu-toggle:not(.is-active):hover .hamburger-icon span { background-color: #000; }
.hamburger-menu-toggle.is-active:hover .hamburger-icon span:nth-child(1),
.hamburger-menu-toggle.is-active:hover .hamburger-icon span:nth-child(3) { background-color: #333; }
.hamburger-menu-toggle:focus { outline: 2px solid #007bff; outline-offset: 2px; }
.hamburger-menu-toggle:focus:not(:focus-visible) { outline: none; }

.user-dropdown-menu { position: absolute; top: calc(100% + 8px); right: 0; background-color: #fff; border: 1px solid #e0e0e0; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 1000; min-width: 160px; padding: 8px 0; opacity: 0; visibility: hidden; transform: translateY(10px); transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out, visibility 0s linear 0.2s; }
.user-dropdown-menu.is-open { opacity: 1; visibility: visible; transform: translateY(0); transition-delay: 0s; }
.user-dropdown-menu ul { list-style: none; padding: 0; margin: 0; }
.user-dropdown-menu li { margin: 0; } 
.logout-form-dropdown { margin: 0; }
.dropdown-menu-item-button, .dropdown-menu-item-link { display: block; width: 100%; padding: 10px 18px; text-align: left; background: none; border: none; color: #222; font-size: 0.95rem; font-family: inherit; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out; }
.dropdown-menu-item-button:hover, .dropdown-menu-item-button:focus,
.dropdown-menu-item-link:hover, .dropdown-menu-item-link:focus { background-color: #f5f5f5; color: #007bff; outline: none; }

/* --- Forms (login.html, signup.html) --- */
.form-group { margin-bottom: 1em; }
.form-group label { display: block; margin-bottom: 0.3em; font-weight: 500; font-size: 0.9rem; text-align: left; color: #333; }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; font-family: inherit; line-height: inherit; box-sizing: border-box; transition: border-color 0.15s ease-in-out; background-color: #fff; color: #333; }
.form-control:focus { border-color: #007bff; outline: none; box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25); }
.button { display: inline-block; padding: 10px 18px; font-size: 1rem; font-weight: 500; text-align: center; text-decoration: none; border-radius: 4px; cursor: pointer; transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out; border: 1px solid transparent; line-height: 1.4; }
.button-primary { background-color: #000; color: #fff !important; border-color: #000; }
.button-primary:hover { background-color: #333; border-color: #333; text-decoration: none; color: #fff !important; }
.button-secondary { background-color: transparent; color: #555 !important; border: 1px solid #ccc; }
.button-secondary:hover { background-color: #f0f0f0; color: #333 !important; border-color: #bbb; text-decoration: none; }
a.button, a.button:visited { text-decoration: none; }
a.button:hover { text-decoration: none; }
.form-actions { margin-top: 1.5em; }
.auth-form .form-actions .button { width: 100%; }
.error-summary { border-left: 3px solid #dc3545; padding: 10px 12px; margin: 1em 0; background-color: #f8d7da; color: #721c24; border-radius: 4px; }
.error-summary ul { list-style-type: disc; padding-left: 1.5em; margin: 0; }
.error-summary li { margin-bottom: 0.3em; }
.form-link { margin-top: 2em; font-size: 0.9em; }
.form-link a { color: #555; }

/* --- Bible Navigation (bible_home.html) --- */
.bible-navigation-container { margin-top: 1.5em; }
.book-sort-controls { display: flex; margin-bottom: 1.5em; border: 1px solid #d0d0d0; border-radius: 6px; overflow: hidden; }
.sort-button { flex-grow: 1; padding: 10px 15px; font-size: 0.95rem; font-weight: 500; text-align: center; background-color: #f0f0f0; color: #444; border: none; cursor: pointer; transition: background-color 0.2s, color 0.2s; }
.sort-button:not(:last-child) { border-right: 1px solid #d0d0d0; }
.sort-button.active { background-color: #333; color: #fff; }
.sort-button:hover:not(.active) { background-color: #e0e0e0; }
.bible-nav-heading { display: none; } 
.book-list-accordion { border-top: 1px solid #dcdcdc; }
.book-item-accordion { border-bottom: 1px solid #dcdcdc; }
.book-title-toggle { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 16px 10px; background-color: #fff; border: none; text-align: left; font-size: 1rem; color: #333; cursor: pointer; transition: background-color 0.2s; }
.book-title-toggle:hover, .book-title-toggle:focus { background-color: #f7f7f7; outline: none; }
.book-title-toggle.open { background-color: #f0f0f0; } 
.book-name-display { display: flex; flex-direction: column; gap: 2px; }
.book-name-zh-accordion { font-weight: 500; color: #000; font-size: 1.2rem; line-height: 1.3; }
.book-name-en-accordion { font-size: 0.90rem; color: #555; line-height: 1.3; }
.book-chevron { margin-left: 10px; display: flex; align-items: center; }
.chevron-icon { width: 1em; height: 1em; fill: currentColor; transition: transform 0.3s ease-in-out; }
.book-title-toggle.open .chevron-icon { transform: rotate(180deg); }
.chapter-grid-container { background-color: #f9f9f9; padding: 12px; display: none; }
.chapter-grid-loader { text-align: center; padding: 20px; color: #777; font-style: italic; }
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 8px; }
.chapter-tile { display: flex; justify-content: center; align-items: center; aspect-ratio: 1 / 1; padding: 8px; background-color: #fff; border: 1px solid #ccc; border-radius: 4px; text-decoration: none; font-size: 1rem; font-weight: 500; color: #444; transition: background-color 0.2s, border-color 0.2s, color 0.2s; }
.chapter-tile:hover, .chapter-tile:focus { background-color: #333; color: #fff; border-color: #000; text-decoration: none; outline: none; }
.error-text { color: #c00; font-style: normal; font-size: 0.9rem; padding: 10px 0;}

/* --- Read View specific styles --- */
.read-page-container { } 
.read-view-main-header { display: flex; justify-content: space-between; align-items: center; height: 60px; padding: 0 16px; margin-bottom: 0.5em; }
.chapter-title-block { flex-grow: 1; display: flex; justify-content: center; align-items: center; text-align: center; height: 100%; }
.chapter-title-main { font-size: 1.5rem; font-weight: 400; color: #222; margin: 0; line-height: 1.2; }
.chapter-nav-button { display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; text-decoration: none; color: #333; background-color: #f8f9fa; border: 1px solid #d0d0d0; border-radius: 6px; font-size: 0.95rem; font-weight: 500; transition: background-color 0.2s, color 0.2s, border-color 0.2s; white-space: nowrap; flex-shrink: 0; min-width: 80px; height: 38px; box-sizing: border-box; }
.chapter-nav-button:hover, .chapter-nav-button:focus { background-color: #e9ecef; color: #000; border-color: #bbb; text-decoration: none; outline: none; }
.chapter-nav-button.prev .chapter-nav-arrow { margin-right: 0.4em; }
.chapter-nav-button.next .chapter-nav-arrow { margin-left: 0.4em; }
.chapter-nav-arrow { font-size: 1em; }
.chapter-nav-button-placeholder { display: inline-block; min-width: 80px; height: 38px; visibility: hidden; }

.bottom-chapter-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 2.5em; margin-bottom: 1em; }

.verses-reading-area { margin-top: 1em; margin-right: 0.5em; } 
.verse-block { display: flex; align-items: baseline; margin-bottom: 0.8em; line-height: 1.75; }
.verse-number { color: #777; font-size: 0.8em; margin-right: 0.6em; min-width: 1.8em; text-align: right; flex-shrink: 0; }
.verse-text-content { text-align: justify; word-break: keep-all; line-break: strict; flex-grow: 1; min-width: 0; }

/* Word Styling - Based on your latest version */
.word {
/*   padding: 0px 0px; 
  margin: 0px 0px; 
  display: inline-block;
  cursor: pointer;
  color: #D9534F;
  text-decoration: none;
  transition: background-color 0.15s ease-in-out, 
              border-color 0.15s ease-in-out, 
              color 0.15s ease-in-out;
  white-space: normal; */
  padding: 0 0;
  margin: 0 0;
  display: inline-block;
  cursor: pointer;
  color: red;
  text-decoration: none;
  /* border-bottom: 1px dashed transparent; */
  /* border-radius: 3px; */
  transition:
    background-color 0.2s ease-in-out,
    border-color 0.2s ease-in-out,
    color 0.2s ease-in-out;
}
.word:hover {
  /* background-color: #f5f5f5;  */
  background-color: #f0f0f0;
  border-bottom-color: #ccc;
}
.word.learning {
  color: #6A0DAD; /* Purple for learning */
  border-bottom-color: #6A0DAD; /* Ensure border color matches text */
  border-bottom: 2px solid; /* Your chosen style for learning */
}
.word.learning:hover {
  background-color: #f0f0f5; 
}
.word.known {
/*   color: #212121; 
  text-decoration: none;
  border-bottom-color: transparent;
  cursor: pointer;  */
  /* background-color: #e6ffe6; */
  /* color: #28a745; */
  color: black;
  text-decoration: none;
  border-bottom-color: transparent;
}
.word.known:hover {
   background-color: #f9f9f9; 
}

/* UPDATED: word-no-definition (was .word-not-in-db) */
.word-no-definition {
  display: inline-block;
  color: #9E9E9E; 
  cursor: default; 
  padding: 0px 0px; 
  margin: 0px 0px;  
  white-space: normal;
  border-radius: 3px; /* Add a slight radius if you use background hover */
  transition: background-color 0.15s ease-in-out; /* Smooth transition */
}
.word-no-definition:hover {
  background-color: #f5f5f5; /* Very light grey, same as .word:hover */
                                /* Or an even lighter one like #fafafa */
}


/* --- Display Settings Panel (Popover) --- */
.display-settings-panel { position: absolute; top: calc(100% + 8px); right: 0; background-color: #fff; border: 1px solid #d0d0d0; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 1000; width: auto; min-width: 160px; padding: 12px; opacity: 0; visibility: hidden; transform: translateY(10px); transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out, visibility 0s linear 0.2s; }
.display-settings-panel.is-open { opacity: 1; visibility: visible; transform: translateY(0); transition-delay: 0s; }
.display-settings-panel .panel-label { display: block; font-size: 0.95rem; font-weight: normal; color: #222; margin-bottom: 8px; text-align: left; }
.font-size-controls-panel { display: flex; align-items: center; background-color: #f0f0f0; border: 1px solid #b0b0b0; border-radius: 6px; overflow: hidden; }
.font-control-button { background-color: transparent; border: none; color: #333; font-family: inherit; font-size: 1.1rem; font-weight: 400; flex-grow: 1; padding: 8px 10px; text-align: center; cursor: pointer; transition: background-color 0.15s ease-in-out; display: flex; align-items: center; justify-content: center; height: 34px; }
.font-control-button:hover { background-color: #e0e0e0; }
.font-control-button:active { background-color: #d0d0d0; }
.font-control-button svg { width: 1em; height: 1em; stroke: currentColor; }
.font-size-current-value { font-size: 0.9rem; font-weight: 500; color: #222; padding: 0 10px; border-left: 1px solid #b0b0b0; border-right: 1px solid #b0b0b0; background-color: #fff; min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; display: flex; align-items: center; justify-content: center; height: 34px; }

/* --- Display Settings Toggle Button --- */
.display-settings-container { position: relative; display: inline-block; vertical-align: middle; margin-left: 10px; }
.display-settings-toggle { background: none; border: none; padding: 8px; margin: 0; cursor: pointer; line-height: normal; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; width: 38px; height: 38px; vertical-align: middle; }
.display-settings-toggle .icon-font-settings-img { display: block; width: 22px; height: 22px; }
.display-settings-toggle:hover { background-color: #f0f0f0; }
.display-settings-toggle:focus { outline: 2px solid #007bff; outline-offset: 2px; }
.display-settings-toggle:focus:not(:focus-visible) { outline: none; }

/* --- Word Action Popover --- */
/* Using Option A (iOS-like) from previous suggestions - adapt if you preferred Option B */
.word-action-popover {
  position: absolute; 
  background-color: rgba(249, 249, 249, 0.96); /* Slightly translucent */
  border: 1px solid #d0d0d0; 
  border-radius: 8px; 
  box-shadow: 0 3px 8px rgba(0,0,0,0.1); /* Softer shadow for popover */
  padding: 10px; 
  z-index: 1001; 
  display: none; 
  min-width: 150px; /* Ensure buttons have enough space */
  box-sizing: border-box;
}
.word-action-popover .popover-word-text-display { /* Matching ID from HTML */
  font-weight: 600; 
  color: #111;
  margin-bottom: 10px;
  text-align: center;
  font-size: 1.1em; 
  line-height: 1.3;
}
.word-action-popover .popover-actions {
  display: flex;
  flex-direction: column;
  gap: 6px; /* Slightly tighter gap for popover buttons */
}
/* Style popover buttons to feel native / simple */
.word-action-popover .popover-actions .button {
  width: 100%; 
  padding: 9px 12px; /* Adjusted padding for popover buttons */
  font-size: 0.95rem; 
  font-weight: 400; /* Normal weight for popover action text */
  line-height: 1.4;
  background-color: #f8f9fa; /* Light background, similar to nav buttons */
  color: black !important; /* Action blue color for text */
  border: 1px solid #d0d0d0; /* Subtle border */
  border-radius: 6px; /* Consistent rounded corners */
}
.word-action-popover .popover-actions .button:hover {
  background-color: #e9ecef; /* Slightly darker on hover */
  border-color: #bbb;
  color: #0056b3 !important;
}


/* --- Modal & Toast --- */
.modal { display: none; position: fixed; z-index: 1050; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4); padding-top: 5vh; }
.modal-content { background-color: #fff; margin: 0 auto; padding: 20px 25px; border: none; width: 90%; max-width: 480px; border-radius: 10px; position: relative; box-shadow: 0 5px 15px rgba(0,0,0,0.15); }
.modal-close-button { color: #888; position: absolute; top: 12px; right: 15px; font-size: 28px; font-weight: bold; line-height: 1; }
.modal-close-button:hover, .modal-close-button:focus { color: #333; text-decoration: none; cursor: pointer; }
.modal h3#modalWordText { margin-top: 0; font-size: 1.6rem; font-weight: 500; color: #111; margin-bottom: 0.4em; text-align: center; }
.modal p#modalWordPinyin { font-style: italic; color: #444; margin-bottom: 0.8em; text-align: center; font-size: 1rem;}
.modal p#modalWordDefinition { text-align: center; margin-bottom: 0.5em; line-height: 1.65; font-size: 1rem; color: #333; }

.toast-notification { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background-color: rgba(17,17,17,0.85); color: white; padding: 10px 18px; border-radius: 20px; z-index: 2001; font-size: 0.9rem; box-shadow: 0 2px 8px rgba(0,0,0,0.2); opacity: 0; transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, bottom 0.3s ease-in-out; pointer-events: none; }
.toast-notification.show { opacity: 1; bottom: 30px; transform: translateX(-50%) translateY(0); }


/* --- Footer / Feedback (General) --- */
.footer-divider { margin-top: 0.5em; border-top: 1px solid #eee; } 
.feedback-text { margin-top: 0.5em; margin-bottom:0; font-size: 0.85em; color: #777; text-align: left; }

/* --- Landing Page Specific Styles --- */
/* These should be in landing.html's <style> block for better modularity */

/* --- Authentication Page Specific Styles --- */
.auth-page-container { padding-top: 20px; padding-bottom: 30px; }
.auth-header { text-align: left; margin-bottom: 2em; }
.auth-header .logo-text { font-size: 1.5rem; margin-bottom: 0.1em; line-height: 1.2; }
.auth-header .logo-link { text-decoration: none; }
.auth-header .logo-link:hover { text-decoration: none; }
.auth-header .tagline { font-size: 1rem; color: #666; margin-bottom: 1em; } 
.form-wrapper { background-color: #fdfdfd; padding: 20px 25px 25px 25px; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.07); max-width: 450px; margin-left: auto; margin-right: auto; }
.form-title { text-align: center; font-size: 1.6rem; font-weight: 400; color: #111; margin-top: 0; margin-bottom: 1.2em; }
.login-notice { color: #555; background-color: #fffbe6; border: 1px solid #ffe58f; padding: 10px 12px; border-radius: 4px; margin-bottom: 1.5em; font-size: 0.9rem; }
.auth-form { margin-top: 0; }
.auth-form .form-group label { text-align: left; }
.auth-form .form-actions .button { width: 100%; }
.auth-page-container .form-link { text-align: center; margin-top: 1.8em; font-size: 0.95rem; }
.auth-feedback-text { text-align: center; margin-top: 0.5em; font-size: 0.9em; }


/* --- Media Queries for Larger Screens --- */
@media (min-width: 768px) {
  body { font-size: 17px; } 
  .container { padding: 30px 20px; max-width: 720px; } 
  
  h1.logo-text, .top-nav .logo-text, .landing-header .logo-text, .auth-header .logo-text { 
      font-size: 1.65rem !important; 
      line-height: 1.2 !important;
  }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.3rem; }
  
  .read-view-main-header .chapter-title-main { font-size: 1.8rem; }
  .chapter-nav-button { font-size: 1rem; padding: 10px 18px; min-width: 90px; height: 40px; }
  .chapter-nav-button-placeholder { min-width: 90px; height: 40px; }
  .verses-reading-area { font-size: 1.05em; }

  .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(55px, 1fr)); gap: 10px; }
  .chapter-tile { font-size: 1.05rem; }
  .book-sort-controls { max-width: 300px; margin-left: auto; margin-right: auto; }
  .book-name-zh-accordion { font-size: 1.25rem; }
  .book-name-en-accordion { font-size: 0.95rem; }

  .auth-page-container { max-width: 720px; } 
  .auth-header .tagline { font-size: 1.15rem; } 
  .form-title { font-size: 1.75rem; }
  .form-wrapper { padding: 25px 30px 30px 30px; }
}