/* ============================================
   WORD PAGE BASE STYLES
   ============================================ */

/* Word page container */
.word-container {
  width: 100%;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
}

.word-header {
  text-align: right;
  margin-bottom: 20px;
  padding: 0 20px;
  width: 100%;
  box-sizing: border-box;
}

.word-logo {
  display: inline-block;
}

.word-logo img {
  max-width: 162px;
  height: auto;
}

.word-entries {
  max-width: 800px;
  margin: 0 auto;
}

.word-separator {
  text-align: center !important;
  padding: 10px 0;
  color: #7f7fdf;
}

/* Word footer - separate table */
.word-footer {
  max-width: 800px;
  margin: 0 auto;
  padding-top: 20px;
  padding-right: 158px;
  text-align: right;
  box-sizing: border-box;
}

.word-footer table {
  display: inline-block;
  border-collapse: collapse;
}

.word-footer-row td {
  padding-top: 3px;
  vertical-align: top;
  width: 50%;
}

.word-footer-row td:first-child {
  text-align: right;
  padding-right: 3px;
}

.word-footer-row td:last-child {
  text-align: left;
  padding-left: 3px;
}

/* Word entries table */
.word-entries table {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  border-collapse: collapse;
}

.word-entries tr {
  display: table-row;
}

.word-entries td {
  padding: 3px 3px;
}

/* Smart wrapping for entry content (middle column) */
.word-entries td[width="300"] {
  max-width: 300px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Desktop: align name and timestamp to bottom, entry to top */
@media screen and (min-width: 481px) {

  .word-entries td:nth-child(1),
  .word-entries td:nth-child(3) {
    vertical-align: bottom;
  }

  .word-entries td:nth-child(2) {
    vertical-align: top;
  }
}

/* Mobile: stack vertically with top alignment */
@media screen and (max-width: 480px) {
  .word-entries td {
    vertical-align: top;
  }

  /* Remove max-width constraint on mobile to fill screen */
  .word-entries td[width="300"] {
    max-width: none;
  }
}

/* Word title row */
.word-entries tr:nth-child(2) td {
  text-align: right;
  padding: 0 20px !important;
  vertical-align: middle !important;
  /* Smart word wrapping - prefer breaking at underscores */
  overflow-wrap: anywhere;
  word-break: break-word;
  /* Allow breaking at hyphens and underscores */
  hyphens: manual;
}

/* Base styles to match original */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background-color: #10103f;
  color: #7f7fdf;
  font-family: Times, "Times New Roman", serif;
}

a {
  color: #9f9fff;
  text-decoration: underline;
}

a:visited {
  color: #7f7fdf;
}

/* Center everything in the viewport */
body {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Override for recent page - no vertical centering */
body:has(.recent-container) {
  display: block;
  align-items: unset;
}

/* Override for word page - no vertical centering */
body:has(.word-container) {
  display: block;
  align-items: unset;
}

/* Main container with fixed width to match original */
.main-container {
  width: 400px;
  margin: 0 auto;
  /* Center the container */
}

/* Top row with image and text */
.top-row {
  display: flex;
  align-items: flex-end;
  line-height: 0;
  /* Remove extra space around images */
}

.top-left {
  width: 200px;
  text-align: right;
  line-height: 0;
  /* Remove extra space around images */
}

.top-left img {
  display: inline-block;
  /* Allow text-align to work */
}

.top-right {
  width: 200px;
  font-size: smaller;
  line-height: 1.2;
}

/* Bottom row with corner images */
.bottom-row {
  display: flex;
  align-items: flex-start;
  line-height: 0;
  /* Remove extra space around images */
}

.bottom-left {
  width: 200px;
  text-align: right;
  line-height: 0;
  /* Remove extra space around images */
}

.bottom-left img {
  display: inline-block;
  /* Allow text-align to work */
}

.bottom-right {
  text-align: left;
  line-height: 0;
  /* Remove extra space around images */
}

.bottom-right img {
  display: block;
  /* Remove inline spacing */
}

/* Footer with copyright */
.footer {
  text-align: center;
  margin-top: 75px;
  font-size: smaller;
  color: #45458f;
}

/* Paragraph spacing to match original */
p {
  margin: 0.5em 0;
}

/* Mobile responsiveness - scale down while maintaining layout */
@media screen and (max-width: 480px) {
  body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 0;
  }

  .main-container {
    width: 100%;
    max-width: 100%;
    padding: 10px 10px 0 10px;
    box-sizing: border-box;
    transform-origin: top center;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
  }

  .content-area {
    flex: 0 0 auto;
  }

  /* Maintain proportional widths on mobile */
  .top-left,
  .bottom-left {
    width: 50%;
  }

  .top-right,
  .bottom-right {
    width: 50%;
  }

  /* Scale images to fit mobile while maintaining alignment */
  .top-left img,
  .bottom-left img,
  .bottom-right img {
    max-width: 100%;
    height: auto;
    display: block;
  }

  /* Keep right alignment for left images */
  .top-left img,
  .bottom-left img {
    margin-left: auto;
  }

  /* Keep left alignment for right images */
  .bottom-right img {
    margin-right: auto;
  }

  /* Allow text to scale with viewport */
  .top-right {
    font-size: 0.75rem;
    line-height: 1.3;
  }

  .footer {
    font-size: 0.7rem;
    margin-top: auto;
    padding: 150px 10px 20px 10px;
    width: 100%;
    box-sizing: border-box;
  }
}

/* Recent page specific styles */
.recent-container {
  width: auto;
  max-width: 800px;
  margin: 0 auto;
}

.recent-columns {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 10px;
}

.recent-column {
  flex: 1 1 0;
  min-width: 0;
}

.recent-today {
  text-align: right;
}

.recent-today .recent-words {
  align-items: flex-end;
}

.recent-yesterday {
  text-align: left;
}

.recent-yesterday .recent-words {
  align-items: flex-start;
}

.recent-header {
  margin-bottom: 15px;
  font-weight: bold;
}

.recent-words {
  display: flex;
  flex-direction: column;
}

.recent-words a {
  display: inline-block;
  margin-bottom: 2px;
}

/* Mobile styles for recent page */
@media screen and (max-width: 480px) {

  /* Add padding to body for comfortable reading */
  body:has(.recent-container) {
    padding: 0 20px;
    box-sizing: border-box;
  }

  /* Make the outer table responsive */
  body:has(.recent-container)>table {
    width: 100% !important;
    display: block;
  }

  body:has(.recent-container)>table>tbody,
  body:has(.recent-container)>table>tbody>tr {
    display: block;
    width: 100%;
  }

  body:has(.recent-container)>table>tbody>tr>td {
    display: block;
    width: 100% !important;
    height: auto !important;
  }

  /* Remove vertical spacing between image and content */
  body:has(.recent-container)>table>tbody>tr:nth-child(2) {
    display: none;
  }

  /* Stack the recent columns vertically on mobile */
  .recent-container {
    width: 100% !important;
    max-width: 100%;
    padding: 0;
  }

  .recent-columns {
    flex-direction: column;
    gap: 40px;
    width: 100%;
  }

  .recent-column {
    width: 100%;
    max-width: 100%;
  }

  /* Today section - right aligned, appears first on mobile */
  .recent-today {
    text-align: right;
    width: 100%;
  }

  .recent-today .recent-words {
    width: 100%;
  }

  /* Yesterday section - left aligned, appears second on mobile */
  .recent-yesterday {
    text-align: left;
    width: 100%;
  }

  .recent-yesterday .recent-words {
    width: 100%;
  }

  .recent-header {
    margin-bottom: 15px;
  }
}

/* Tablet and small desktop adjustments */
@media screen and (min-width: 481px) and (max-width: 768px) {
  .main-container {
    width: 90%;
    max-width: 400px;
  }
}

/* ============================================
   ADDFORM SPECIFIC STYLES
   ============================================ */

/* Base addform styles */
body.addform-page {
  margin: 0;
}

body.addform-page .outer-table {
  width: 100%;
  height: 100%;
}

/* LOGO GRAPHICS - Remove whitespace on ALL screen sizes */
body.addform-page .logo-row,
body.addform-page .logo-bottom-row {
  line-height: 0;
  margin: 0;
  padding: 0;
}

body.addform-page .logo-row td,
body.addform-page .logo-bottom-row td {
  line-height: 0;
  padding: 0;
  margin: 0;
}

body.addform-page .logo-row img,
body.addform-page .logo-bottom-row img {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  vertical-align: top;
  line-height: 0;
}

/* FORM LABEL SPACING - All screen sizes */
body.addform-page .form-table td:first-child {
  padding-right: 0.3rem;
}

body.addform-page .form-table td {
  padding: 0;
  margin: 0;
  line-height: 1;
}

/* Remove all margins from form inputs */
body.addform-page .form-table input,
body.addform-page .form-table textarea {
  margin: 0 !important;
  display: block;
}

/* HEADER TEXT SPACING - Prevent squishing */
body.addform-page .logo-row td:last-child {
  line-height: 1.2;
  /* Restore normal line height for text */
  padding-top: 0.5rem;
  /* Add some breathing room */
  padding-left: 0;
  /* Remove padding from container */
}

body.addform-page .logo-row td:last-child table {
  margin-bottom: 1rem;
  /* Space before form */
  margin-left: 1rem;
  /* Add space for header text only */
}

/* FORM TABLE VERTICAL SPACING */
body.addform-page .form-table {
  border-spacing: 0 0;
  /* No vertical spacing between rows */
  margin-left: 0.2rem;
  /* Minimal space for form elements */
}

body.addform-page .form-table tr {
  margin: 0;
  padding: 0;
  height: auto;
  line-height: 1;
}

/* SUBMIT TABLE - Minimal styling */
body.addform-page .submit-table {
  border-spacing: 0;
  margin: 0;
  padding: 0;
}

body.addform-page .submit-table td {
  padding: 0;
  margin: 0;
}

body.addform-page .submit-table td {
  padding: 0;
  margin: 0;
}

/* Mobile Portrait and Landscape - Addform */
@media (max-width: 520px),
(max-height: 520px) {

  /* BODY & CONTAINER SPACING */
  body.addform-page {
    padding: 1.5rem 1.5rem 2rem 1.5rem;
    display: block;
    align-items: flex-start;
  }

  /* Safe area support for notched devices */
  @supports (padding: max(0px)) {
    body.addform-page {
      padding-left: max(1.5rem, env(safe-area-inset-left));
      padding-right: max(1.5rem, env(safe-area-inset-right));
      padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
  }

  body.addform-page .outer-table {
    height: auto;
  }

  body.addform-page .addinner {
    width: 100% !important;
    display: block !important;
  }

  /* HIDE DECORATIVE GRAPHICS ON MOBILE */
  body.addform-page .logo-row td:first-child,
  body.addform-page .logo-bottom-row td:first-child {
    display: none !important;
  }

  body.addform-page .logo-row,
  body.addform-page .logo-bottom-row {
    display: block !important;
  }

  /* HEADER TEXT SPACING */
  body.addform-page .logo-row td:last-child {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    margin-bottom: 1.25rem;
    color: #7f7fdf;
  }

  body.addform-page .logo-row td:last-child table {
    margin-left: 0 !important;
  }

  body.addform-page .logo-row td:last-child table td {
    color: #7f7fdf;
  }

  body.addform-page .logo-row td:last-child a {
    color: #9f9fff;
  }

  /* FORM FIELD SPACING - Reduced for mobile */
  body.addform-page .form-table {
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 0.375rem;
    margin-top: 1rem;
  }

  body.addform-page .form-table tr {
    display: block;
  }

  body.addform-page .form-table td {
    display: block;
    width: 100%;
    text-align: left !important;
    padding-bottom: 0.625rem;
    color: #7f7fdf;
  }

  /* Label spacing - override for mobile */
  body.addform-page .form-table td:first-child {
    margin-bottom: 0.5rem;
    padding-right: 0;
    /* Remove horizontal padding on mobile since labels stack */
    font-weight: normal;
    line-height: 1.4;
    color: #7f7fdf !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* INPUT FIELDS - Meet 44px touch target minimum */
  body.addform-page .form-table input[type="text"],
  body.addform-page .form-table textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.875rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    min-height: 44px;
    border: 1px solid rgba(127, 127, 223, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: #7f7fdf;
    transition: border-color 0.2s ease;
  }

  /* Focus states for better UX */
  body.addform-page .form-table input[type="text"]:focus,
  body.addform-page .form-table textarea:focus {
    outline: none;
    border-color: rgba(159, 159, 255, 0.6);
    background: rgba(255, 255, 255, 0.1);
  }

  body.addform-page .form-table textarea {
    min-height: 10rem;
    resize: vertical;
  }

  /* SUBMIT BUTTON - Enhanced spacing & touch target */
  body.addform-page .form-table tr:last-of-type td {
    text-align: center !important;
  }

  body.addform-page .form-table input[type="submit"] {
    padding: 1rem 3rem !important;
    min-height: 50px !important;
    min-width: 200px !important;
    font-size: 1.125rem !important;
    font-family: inherit;
    border: 1px solid rgba(127, 127, 223, 0.4);
    border-radius: 4px;
    background: rgba(127, 127, 223, 0.2);
    color: #7f7fdf;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    margin: 1.25rem auto 0 auto;
  }

  body.addform-page .form-table input[type="submit"]:active {
    background: rgba(127, 127, 223, 0.3);
    transform: translateY(1px);
  }

  /* COPYRIGHT TEXT */
  body.addform-page .addinner tr:last-child td {
    color: #45458f;
  }

  /* EMAIL & SUBMIT ROW SPACING */
  body.addform-page .submit-table {
    width: 100% !important;
  }

  body.addform-page .submit-table td {
    display: block;
    width: 100%;
    padding-bottom: 0;
  }

  body.addform-page .submit-table td:first-child {
    margin-bottom: 1rem;
  }

  body.addform-page .submit-table td:last-child {
    padding-bottom: 0;
  }
}

/* Mobile Landscape Orientation - Addform (handles phone turned sideways) */
@media (max-height: 520px) and (orientation: landscape) {
  body.addform-page {
    padding: 0.5rem 1.5rem 1rem 1.5rem;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
  }

  body.addform-page .outer-table {
    margin-top: 0;
  }

  /* Reduce header spacing in landscape */
  body.addform-page .logo-row td:last-child {
    margin-bottom: 0.75rem;
  }

  /* Reduce form field spacing in landscape */
  body.addform-page .form-table {
    border-spacing: 0 0.25rem;
    margin-top: 0.5rem;
  }

  body.addform-page .form-table td:first-child {
    margin-bottom: 0.25rem;
  }

  body.addform-page .form-table td {
    padding-bottom: 0.375rem;
  }

  /* Reduce textarea height in landscape */
  body.addform-page .form-table textarea {
    min-height: 6rem;
  }

  /* Reduce submit button spacing */
  body.addform-page .form-table input[type="submit"] {
    margin: 0.75rem auto 0 auto;
    padding: 0.75rem 2.5rem !important;
    min-height: 44px !important;
  }
}

/* Mobile Landscape - Addform */
@media (min-width: 521px) and (max-width: 767px) {
  body.addform-page {
    padding: 2rem 2rem 2.5rem 2rem;
  }

  body.addform-page .form-table {
    border-spacing: 0 1.75rem;
  }

  body.addform-page .form-table input[type="text"],
  body.addform-page .form-table textarea {
    padding: 1rem 1.125rem;
    font-size: 1.0625rem;
  }

  body.addform-page .submit-cell {
    margin-top: 1.5rem;
  }

  body.addform-page .submit-cell input[type="submit"] {
    padding: 1rem 2.5rem;
    font-size: 1.0625rem;
  }
}

/* Tablet Portrait - Addform */
@media (min-width: 768px) and (max-width: 1024px) {
  body.addform-page {
    padding: 2.5rem 3rem;
  }

  body.addform-page .addinner {
    max-width: 500px;
    margin: 0 auto;
  }

  body.addform-page .form-table {
    border-spacing: 0 2rem;
  }

  body.addform-page .form-table input[type="text"],
  body.addform-page .form-table textarea {
    padding: 1.125rem 1.25rem;
    font-size: 1.125rem;
  }

  body.addform-page .submit-cell input[type="submit"] {
    padding: 1.125rem 3rem;
    font-size: 1.125rem;
  }
}

/* ============================================
   WORD PAGE SPECIFIC STYLES
   ============================================ */

/* Word page mobile responsiveness */
@media screen and (max-width: 480px) {

  /* Word page container adjustments */
  body:has(.word-container) {
    display: block;
    padding: 0;
  }

  .word-container {
    padding: 15px;
  }

  .word-header {
    margin-bottom: 15px;
  }

  .word-logo img {
    max-width: 120px;
  }

  .word-title-section {
    margin: 20px 0 15px 0;
  }

  .word-title {
    font-size: 1.2rem;
    padding: 10px 20px;
    max-width: 90%;
    word-wrap: break-word;
  }

  .word-entries {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  /* Word entries table on mobile */
  .word-entries>table {
    width: 100%;
  }

  .word-entries>table>tbody>tr,
  .word-entries>table>tr {
    display: block;
    margin-bottom: 20px;
  }

  .word-entries>table>tbody>tr>td,
  .word-entries>table>tr>td {
    display: block;
    width: 100% !important;
    padding: 5px 0 !important;
    text-align: left !important;
  }

  /* Word title row */
  .word-entries>table>tbody>tr:first-child,
  .word-entries>table>tr:first-child {
    display: none;
    /* Hide spacer row */
  }

  .word-entries>table>tbody>tr:nth-child(2),
  .word-entries>table>tr:nth-child(2) {
    margin-bottom: 20px;
  }

  .word-entries>table>tbody>tr:nth-child(2)>td,
  .word-entries>table>tr:nth-child(2)>td {
    text-align: right !important;
    padding: 10px 0 !important;
  }

  /* Separator rows */
  .word-entries>table>tbody>tr:has(td[align="center"]),
  .word-entries>table>tr:has(td[align="center"]) {
    margin-bottom: 10px;
  }

  .word-entries>table>tbody>tr:has(td[align="center"])>td,
  .word-entries>table>tr:has(td[align="center"])>td {
    text-align: center !important;
    padding: 8px 0 !important;
  }

  .word-separator {
    padding: 8px 0;
    font-size: 1rem;
  }

  /* Footer on mobile - two rows, two columns, right aligned */
  .word-footer {
    padding: 20px 15px 0 15px;
    border-top: 1px solid #7f7fdf;
    text-align: right;
  }

  .word-footer table {
    width: auto;
    min-width: 280px;
    border-collapse: collapse;
    display: inline-table !important;
    table-layout: auto;
  }

  .word-footer-row {
    display: table-row !important;
  }

  .word-footer-row td {
    display: table-cell !important;
    padding: 5px 5px !important;
    font-size: 0.9rem;
    vertical-align: top;
  }

  .word-footer-row td:first-child {
    text-align: right !important;
    padding-right: 10px !important;
  }

  .word-footer-row td:last-child {
    text-align: left !important;
    padding-left: 0 !important;
  }
}

/* Tablet adjustments for word pages */
@media screen and (min-width: 481px) and (max-width: 768px) {
  .word-container {
    max-width: 700px;
    padding: 25px;
  }

  .word-title {
    font-size: 1.6rem;
  }
}