:root {
  --bg: #111;
  --fg: #eee;
  --accent: #a3e4c9;
  --font-size: 1.1em;
  --header-bg: #080f19;
  --nav-bg: #1e2733;
  --button-active: #a3e4c9; /* Defined for sticky-active */
}

html {
  scrollbar-gutter: stable;
}

header {
  background-color: var(--header-bg);
  padding: 20px;
  text-align: center;
  margin-bottom: 0;
}

header h1,
header h2,
header h3,
header h4,
header h5,
header h6 {
  color: var(--accent);
}

header p,
footer p {
  color: var(--fg);
}

header a:link,
footer:link a {
  color: var(--accent);
  text-decoration: none;
}

header a:hover,
footer a:hover {
  text-decoration: underline;
  color: #f2d7c9;
}

header a:visited,
footer a:visited {
  color: var(--accent);
}

.primary-donate-link,
.share-intents a {
  display: inline-block;
  padding: 8px 14px;
  border: 2px solid var(--accent);
  color: var(--bg);
  background: var(--accent);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
}

.primary-donate-link:hover,
.share-intents a:hover {
  filter: brightness(1.05);
}

/* Ensure good contrast in header for donate button */
header .primary-donate-link { color: #111 !important; }

footer {
  margin-top: 32px;
}

body {
  font-family: sans-serif;
  font-size: var(--font-size);
  text-align: center;
  background-color: var(--bg);
  color: var(--fg);
}

nav {
  background-color: var(--nav-bg);
  padding: 10px;
  text-align: center;
  border-radius: 0;
  margin: 0;
  max-width: none;
}

#mode-select {
  display: flex;
  justify-content: center;
  gap: 10px;
}

button {
  margin: 0;
  padding: 10px 20px;
  font-size: 1em;
  border-radius: 5px;
  border: 2px solid var(--accent);
  background-color: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

button:hover {
  background-color: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

button.sticky-active {
  background-color: var(--button-active);
  color: var(--bg);
  border-color: var(--button-active);
}

#cover-generator {
  /* display: block; -- Handled by JS or default block behavior */
  padding-top: 32px;
}

#poster-generator {
    display: none; /* Hide poster generator by default, JS handles visibility */
}


.canvas-container {
  margin-top: 8px;
  position: relative;
  display: flex;
  max-width: 300px;
  width: auto;
  justify-content: center;
  margin:0 auto;
}

canvas {
  border: 1px solid #ccc; 
  width: 100%;
  max-width: 540px;
  height: auto;
  touch-action: none;
}

.generator {
  margin-top: 20px;
  margin: 20px auto;
  max-width: unset;
  width: 100%;
  background-color: transparent;
  box-shadow: none;
  padding: 0 0 50px 0;
}

.generator .box {
  background-color: #222;
  padding: 16px 20px;
  border-radius: 10px;
  margin: 16px auto;
  max-width: 540px;
  text-align: left;
  box-sizing: border-box;
}

.generator .box:has(.template-selector),
.generator .box:has(.canvas-container) {
    text-align: center;
}

.generator .box + .box {
  margin-top: 24px;
}

.box label {
  display: block;
  text-align: left;
  max-width: 100%;
  font-weight: bold;
  color: var(--accent);
}

/* Add this new style rule to style.css */
.poster-image-inputs {
  display: flex;
  gap: 20px; /* Add some space between the inputs */
  margin: 0 auto;
  max-width: 540px;
}

.poster-image-inputs > .box {
  margin:0 auto;
  padding:0;
}

/* Target the labels within the flex container to take full width */
.poster-image-inputs > .box > label {
    width: 100%; /* Make labels take full width of their parent */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

/* Target the inputs within the flex container to take 50% width */
.poster-image-inputs > .box > input[type="file"] {
    width: 100%; /* Make inputs take half the width of their parent */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

.label-description {
  font-size: 0.8em;
  font-weight: normal;
  color: #ccc;
  display: block;
  margin-top: 3px;
}

.box input[type="file"],
.box input[type="text"],
.box input[type="color"],
.box textarea,
.box select {
  width: 100%;
  box-sizing: border-box;
  background-color: #333;
  color: var(--fg);
  border: 1px solid #555;
  padding: 8px;
  border-radius: 5px;
  margin-bottom: 10px;
  margin-top: 7px;
}
.box input[type="color"] {
    height: 40px;
    padding: 2px;
}

.box textarea {
  height: 100px;
  resize: vertical;
}

.template-thumb {
  width: 100px;
  margin: 3px;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.template-thumb:hover {
  border-color: var(--accent);
}

.button-group {
  display: flex;
  width: 100%;
  margin-top: 7px;
}

.button-group button {
  flex-grow: 1;
  border-radius: 0;
  margin: 0;
  border-left-width: 0;
}

.button-group button:first-child {
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
  border-left-width: 2px;
}

.button-group button:last-child {
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
}
.button-group button:not(:first-child) {
    border-left-width: 1px;
}

/* Allow button groups to wrap on smaller screens for new scenario options */
.button-group { flex-wrap: wrap; gap: 6px; }
.button-group button { flex: 1 1 auto; }

/* Aug 8 templates */
.aug-template-selector { display: flex; flex-wrap: wrap; justify-content: center; }
.aug-controls { margin-top: 8px; }

/* =========================================================
   Poster Generator Specifics
   =========================================================*/
#poster-generator {
  padding-top: 32px;
}

#poster-interactive-area {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 20px auto 0;
  padding: 0 10px;
  max-width: 1000px; /* Max width for the two-column layout */
}

.poster-controls-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 540px; /* Add this line */
  margin: 0 auto;
}

#simple-mode.color-options,
#advanced-mode.color-options {
  background-color: #222;
  padding: 16px 20px;
  border-radius: 10px;
  text-align: left;
  box-sizing: border-box;
}


/* Simple Mode Radio Button Styling */
#simple-mode.color-options label {
  display: block;
  margin-top: 8px;
  font-weight: normal; /* All preset labels will now have normal weight */
  cursor: pointer;
  color: var(--fg); /* Ensure labels have a readable color, inheriting from body */
}

/* Corrected selector: space instead of colon after label */
#simple-mode.color-options label input[type="radio"] {
  width: auto;
  margin-right: 8px;
  vertical-align: middle;
  /* Resetting specific styles that might be inherited from .box input */
  padding: 0; 
  border: none; 
  background: none; 
  margin-bottom: 0;
  margin-top: 0; /* margin-top is handled by the label's margin-top */
}

/* Advanced Mode Color Picker Row Styling */
#advanced-mode.color-options .color-picker-row {
    display: flex;
    /* Use flex-start if you want label right next to input.
       The 'order' property will place the input first visually. */
    justify-content: flex-start;
    align-items: center;
    margin-top: 8px;
}


#advanced-mode.color-options .color-picker-row label {
    margin-bottom: 0;
    font-weight: normal;
    /* margin-right: 10px; -- REMOVED */
    margin-left: 10px; /* Space AFTER the (visually) first element (the input) */
    flex-shrink: 0;
    order: 2; /* Make label the second item visually */
}

#advanced-mode.color-options .color-picker-row input[type="color"] {
    width: 50px;
    height: 28px;
    padding: 1px;
    border-radius: 4px;
    margin-top: 0;
    margin-bottom: 0;
    /* margin-left: auto; -- REMOVED */
    /* No margin-right needed here if label has margin-left */
    flex-shrink: 0;
    order: 1; /* Make input the first item visually */
    appearance: none; /* Standard property */
    border: 0px; 
    background-color: transparent;  
}

.poster-preview-column {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#poster-generator .poster-wrapper {
    display: block;
    overflow: hidden;
    width: 90vw;
    height: calc(90vw * (1350 / 1080));
    position: relative;
    box-sizing: border-box;
    max-width: 540px;
    max-height: calc(540px * (1350 / 1080));
}

#poster {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    transform-origin: top left;
}

.poster-preview {
    width: 100%; height: 100%;
    background: linear-gradient(#0068b5 0%, #3b86c4 50%, #f3b9b9 100%);
    color: #fff;
    font-family: sans-serif;
    overflow: hidden; position: relative; margin: 0;
    box-sizing: border-box; padding: 2vw;
}

/* Add margin to the top of the poster when note-box is hidden */
#poster-generator .poster-preview:not(:has(.note-box:not(.hidden))) {
  padding-top: 17vw; /* Adjust this value as needed */
}

#poster-generator .poster-preview:not(:has(.note-box:not(.hidden))) .ribbon {
  bottom:39vw;
  right:3vw;
}

#poster-generator .poster-preview:not(:has(.note-box:not(.hidden))) .photo-frame {
  margin-bottom: 2vw;
}

.poster-preview h1 { margin: 2vw 0 0; font-size: 10vw; line-height: 1; text-align: center; }
.poster-preview h2 { margin: 0 0 3vw; font-size: 5vw; text-align: center; }
.photos { display: flex; justify-content: center; gap: 2vw; }
.photo-frame { position: relative; width: 30vw; height: 30vw; border-radius: 2vw; overflow: hidden; background: #eee; }
.photo-frame img { width: 100%; height: 100%; object-fit: contain; cursor: grab; touch-action: none; }
.hidden { display: none !important; }
.tag { position: absolute; top: 1.2vw; left: 1.2vw; background: #0057a3; padding: 0.6vw 2vw; border-radius: 999px; font-size: 1.5vw; font-weight: 600; color: #fff; z-index: 2; }

.name-pill {
    width: 55vw; height: 6vw; margin: 0 auto; transform: translateY(-3vw);
    background: #fff; color: #334; border-radius: 3vw;
    display: flex; align-items: center; justify-content: center;
    font-size: 3.5vw; font-weight: 600; text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
    padding: 0.5vw 1vw; box-sizing: border-box;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

blockquote { width: 70vw; margin: 2vw auto 4vw ; font-size: 4vw; line-height: 1.25; text-align: center; font-weight: 500; overflow-wrap: break-word;}

.note-box {
    width: 75vw; height: 19vw; margin: 0 auto 0vw;
    background: #ffffff; border-radius: 2vw; color: #334;
    font-size: 2.5vw; line-height: 1.2;
    display: flex; align-items: center; justify-content: flex-start; text-align: left;
     padding-top: 2vw; padding-right: 9vw; padding-bottom: 1.5vw; padding-left: 2vw; box-sizing: border-box;
    overflow-wrap: break-word; word-break: break-word;
overflow: hidden; /* This is the key property */

}

.ribbon { position: absolute; right: 3vw; bottom: 9vw; width: 20vw; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4)); z-index: 5; }

/* --- CREDIT STYLING (General VW) --- */
.credit {
    position: absolute;
    bottom: 5vw;     /* Adjust this value if 4vw was too high up */
    left: 2vw;       /* Match parent's left padding */
    right: 2vw;      /* Match parent's right padding */
    /* width is implicitly set by left/right constraints */
    text-align: center;
    font-size: 3vw;
    color: #fff;
}


@media (min-width: 960px) { /* Two-column layout */
    #poster-interactive-area { flex-direction: row; align-items: flex-start; }
    .poster-controls-column { flex: 0 0 320px; /* Fixed width for controls */ }
    .poster-preview-column { flex: 1; min-width: 0; }
    #poster-generator .poster-wrapper {
        width: 100%; height: auto; aspect-ratio: 1080 / 1350; margin: 0;
    }
}

@media (min-width: 600px) { /* Fixed sizes for poster *content* when poster-wrapper is ~540px */
    .poster-preview {
        padding: 12px;  }  /* Fixed padding for the poster frame at this breakpoint */
 
    /* Add margin to the top of the poster when note-box is hidden */
    #poster-generator .poster-preview:not(:has(.note-box:not(.hidden))) {
      padding-top: 101px; /* Adjust this value as needed */
    }

    #poster-generator .poster-preview:not(:has(.note-box:not(.hidden))) .ribbon {
      bottom:235px;
      right:18px;
    }

    #poster-generator .poster-preview:not(:has(.note-box:not(.hidden))) .photo-frame {
      margin-bottom: 12px;
    }

    .poster-preview h1 { font-size: 60px; margin: 12px 0 0; }
    .poster-preview h2 { font-size: 30px; margin: 0 0 18px; }
    .photos { gap: 12px; }
    .photo-frame { width: 180px; height: 180px; border-radius: 12px; }
    .tag { top: 7.2px; left: 7.2px; padding: 3.6px 12px; font-size: 9px; }

    .name-pill {
        width: 330px; height: 36px; transform: translateY(-18px);
        font-size: 21px; border-radius: 18px; padding: 0 10px;
    }

    blockquote { width: 420px; margin: 12px auto 24px; font-size: 24px;  }       

    .note-box {
        width: 450px; height: 113px;
        border-radius: 12px; font-size: 15px; 
        padding-top: 12px; padding-right: 54px; padding-bottom: 9px; padding-left: 12px;
        margin: 0 auto 30px;
    }

    .ribbon { right: 18px; bottom: 54px; width: 120px; }
  
    .credit {
        font-size: 18px;
        bottom: 30px;    /* Adjust if 24px was too high up, should relate to parent padding */
        left: 12px;      /* Match parent's fixed left padding */
        right: 12px;     /* Match parent's fixed right padding */
        /* text-align, color, position:absolute are inherited or already set */
    }
}
