/* Look and feel follow the event page (dac.agilebangladesh.org). Tokens live in tokens.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-cream);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.5;
}

img,
canvas {
  display: block;
  max-width: 100%;
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

h1 {
  font-size: var(--fs-h1);
}

h2 {
  font-size: var(--fs-h2);
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--color-green-deep);
  outline-offset: 3px;
}

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

/* Header and nav: a floating white pill with a black active pill. It scrolls away, so it never covers the editor. */
.nav-wrap {
  display: flex;
  justify-content: center;
  padding: var(--space-2) var(--space-3);
}

.nav-pill {
  display: flex;
  gap: 0.3rem;
  padding: 0.6rem 0.7rem;
  background: var(--color-white);
  border-radius: var(--radius-pill);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

.nav-pill a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  font-size: var(--fs-small);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.nav-pill a.active,
.nav-pill a:hover {
  background: var(--color-dark);
  color: var(--color-white);
}

/* Buttons: pills that lift on hover. Dark text on bright green keeps the contrast readable. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.6rem;
  border: 0;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: var(--fs-small);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    color 0.18s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-green {
  background: var(--color-green-bright);
  color: #0b1a0f;
}

.btn-green:hover:not(:disabled) {
  background: #57cf74;
}

.btn-dark {
  background: var(--color-dark);
  color: var(--color-white);
}

.btn-dark:hover {
  background: #000;
}

.btn-light {
  background: var(--color-white);
  border: 1px solid var(--color-cream-2);
  color: var(--color-text);
}

.btn-light:hover:not(:disabled) {
  background: var(--color-cream);
}

.btn-block {
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }

  .btn:hover {
    transform: none;
  }
}

/* Hero */
.hero {
  padding: var(--space-4) var(--space-3) var(--space-3);
  text-align: center;
}

.hero-logo {
  width: auto;
  height: 240px;
  margin: 0 auto var(--space-3);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-3);
  max-width: max-content;
  margin: 0 auto var(--space-4);
  padding: var(--space-1) var(--space-4);
  list-style: none;
  border-top: 2px solid var(--color-green-deep);
  border-bottom: 2px solid var(--color-green-deep);
}

.hero-meta li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.dot {
  width: 34px;
  height: 34px;
  background: center / contain no-repeat;
}

.dot.date {
  background-image: url('../assets/brand/icon_date.svg');
}

.dot.time {
  background-image: url('../assets/brand/icon_time.svg');
}

.dot.location {
  background-image: url('../assets/brand/icon_location.svg');
}

.lede {
  max-width: 36rem;
  margin: var(--space-2) auto 0;
  color: var(--color-text-muted);
}

/* Small phones: a shorter hero, so the editor starts on the first screen. */
@media (max-width: 599px) {
  .hero {
    padding-top: var(--space-1);
  }

  .hero-logo {
    height: 150px;
    margin-bottom: var(--space-2);
  }

  .hero-meta {
    gap: 0.35rem var(--space-2);
    margin-bottom: var(--space-3);
    padding: 0.35rem var(--space-2);
  }

  .dot {
    width: 26px;
    height: 26px;
  }
}

/* Editor and result layout */
.editor,
.result {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-3) var(--space-5);
}

.editor-grid,
.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  align-items: start;
}

@media (min-width: 900px) {
  .editor-grid,
  .result-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  }
}

/* Cards: white, 16 px radius, 3 px green top border. */
.card {
  padding: var(--space-3);
  background: var(--color-white);
  border: 1px solid var(--color-cream-2);
  border-top: 3px solid var(--color-green);
  border-radius: var(--radius-md);
}

.preview-card canvas {
  width: 100%;
  height: auto;
  background: var(--color-cream-2);
  border-radius: var(--radius-sm);
  cursor: grab;
  touch-action: none;
}

.preview-card canvas:active {
  cursor: grabbing;
}

/* Form */
.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: var(--space-2);
}

label {
  font-size: var(--fs-small);
  font-weight: 600;
}

.optional {
  color: var(--color-text-muted);
  font-weight: 400;
}

input[type='text'],
select,
textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  background: var(--color-white);
  border: 1px solid var(--color-cream-2);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font: inherit;
}

input[type='text']:focus,
select:focus,
textarea:focus {
  border-color: var(--color-green-deep);
  outline: 2px solid var(--color-green-deep);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
}

input[type='file'] {
  font: inherit;
  font-size: var(--fs-small);
}

input[type='range'] {
  width: 100%;
  min-height: 2.75rem; /* a finger-sized hit area; the thumb stays small */
  accent-color: var(--color-green-deep);
}

.photo-controls {
  display: grid;
  gap: var(--space-1);
  margin: 0 0 var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--color-cream-2);
  border-radius: var(--radius-sm);
}

.photo-controls:disabled {
  opacity: 0.5;
}

.photo-controls legend {
  padding: 0 0.35rem;
  font-size: var(--fs-small);
  font-weight: 600;
}

.nudge {
  display: grid;
  grid-template-columns: repeat(3, 2.75rem);
  grid-template-areas:
    '. up .'
    'left . right'
    '. down .';
  gap: 0.35rem;
  justify-content: start;
}

.nudge .btn {
  min-height: 2.75rem;
  padding: 0.5rem;
}

.nudge [data-nudge='up'] {
  grid-area: up;
}

.nudge [data-nudge='left'] {
  grid-area: left;
}

.nudge [data-nudge='right'] {
  grid-area: right;
}

.nudge [data-nudge='down'] {
  grid-area: down;
}

.status {
  min-height: 1.5rem;
  margin: 0 0 var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--fs-small);
}

.status.error,
.counter.error {
  color: var(--color-error);
}

.hint {
  margin: 0.75rem 0 0;
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
}

.form-card .hint {
  margin: 0 0 var(--space-1);
}

.action-bar .status {
  margin-bottom: 0.25rem;
}

/* On a phone the cards stack, and the action bar stays pinned to the bottom of the screen while the form scrolls. */
@media (max-width: 899px) {
  .action-bar {
    position: sticky;
    bottom: 0;
    margin: 0 calc(var(--space-3) * -1) calc(var(--space-3) * -1);
    padding: var(--space-2) var(--space-3);
    background: var(--color-white);
    border-top: 1px solid var(--color-cream-2);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
  }
}

.notice {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  background: var(--color-cream);
  border-radius: var(--radius-sm);
  font-size: var(--fs-small);
}

/* Result */
#result-image {
  width: 100%;
  height: auto;
  margin-top: var(--space-2);
  border-radius: var(--radius-sm);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: var(--space-2) 0;
}

.chip {
  padding: 0.45rem 1rem;
  background: var(--color-white);
  border: 1px solid var(--color-cream-2);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font: inherit;
  font-size: var(--fs-small);
  font-weight: 600;
  cursor: pointer;
}

.chip[aria-pressed='true'] {
  background: var(--color-dark);
  border-color: var(--color-dark);
  color: var(--color-white);
}

.counter {
  margin: 0.5rem 0 0;
  color: var(--color-text-muted);
  font-size: var(--fs-small);
  font-weight: 600;
}

/* Footer: dark, like the event page's footer. */
.site-footer {
  padding: var(--space-4) var(--space-3);
  background: var(--color-dark);
  color: var(--color-text-on-dark-muted);
  font-size: var(--fs-small);
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--color-text-on-dark);
}

/* Guided steps */
.step-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: var(--space-3) 0 var(--space-2);
  font-size: 1.15rem;
}

.step-title:first-child {
  margin-top: 0;
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  background: var(--color-green-bright);
  border-radius: 50%;
  color: #0b1a0f;
  font-size: var(--fs-small);
  font-weight: 700;
}

.photo-pick .btn {
  justify-self: start;
  min-height: 2.75rem;
}

.photo-pick .hint {
  margin: 0;
}

.photo-pick input:focus-visible + .btn {
  outline: 2px solid var(--color-green-deep);
  outline-offset: 3px;
}

/* Preview: sized to the screen, and kept in view beside the form on desktop. */
/* The stage, not the canvas bitmap, sets the size: at a device pixel ratio of 1 a bitmap-sized canvas stays at its first (300 px) width. */
.stage {
  position: relative;
  width: min(100%, calc(72vh * var(--card-ar, 0.6667)));
  margin: 0 auto;
}

.add-photo {
  position: absolute;
  left: var(--win-left, 50%);
  top: var(--win-top, 30%);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.25rem;
  width: var(--win-size, 50%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  color: var(--color-text);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.add-photo[hidden] {
  display: none;
}

.add-photo:hover {
  background: var(--color-white);
}

.add-photo-plus {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  background: var(--color-green-bright);
  border-radius: 50%;
  color: #0b1a0f;
  font-size: 1.75rem;
  line-height: 1;
}

.preview-card.drag-over {
  outline: 2px dashed var(--color-green-deep);
  outline-offset: 3px;
}

@media (min-width: 900px) {
  .preview-card {
    position: sticky;
    top: var(--space-2);
  }
}

/* Style picker */
.styles {
  display: flex;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  padding: 0;
  border: 0;
}

.style-opt {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--color-cream-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.style-opt img {
  width: 54px;
  height: auto;
  border-radius: 4px;
}

.style-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.style-opt:has(input:checked) {
  border-color: var(--color-green-deep);
  background: var(--color-cream);
}

.style-opt:has(input:focus-visible) {
  outline: 2px solid var(--color-green-deep);
  outline-offset: 3px;
}

.chip {
  min-width: 2.75rem;
  min-height: 2.75rem;
}

/* Before a photo is chosen the window is dark, so the typed name stays readable; the add-photo target sits in its upper half. */
.add-photo {
  top: calc(var(--win-top, 30%) - var(--win-size, 50%) * 0.18);
  width: auto;
  aspect-ratio: auto;
  background: none;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.add-photo:hover {
  background: none;
}

.add-photo:hover .add-photo-plus {
  transform: scale(1.08);
}

.status:empty {
  display: none;
}

/* Phones: use the width for the card, and keep the pinned action bar short. */
@media (max-width: 599px) {
  .editor,
  .result {
    padding-inline: 0.75rem;
  }

  .card {
    padding: var(--space-2);
  }

  .action-bar {
    margin: 0 calc(var(--space-2) * -1) calc(var(--space-2) * -1);
    padding: 0.75rem var(--space-2);
  }

  .action-bar .hint {
    margin: 0 0 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .add-photo:hover .add-photo-plus {
    transform: none;
  }
}

/* Text style: segmented controls and colour swatches */
.segment-field,
.swatches {
  margin: 0 0 var(--space-2);
  padding: 0;
  border: 0;
}

.segment-field legend,
.swatches legend {
  padding: 0;
  font-size: var(--fs-small);
  font-weight: 600;
}

.segmented {
  display: inline-flex;
  margin-top: 0.35rem;
  background: var(--color-white);
  border: 2px solid var(--color-cream-2);
  border-radius: var(--radius-pill);
}

.segmented label {
  position: relative;
  display: grid;
  min-height: 2.75rem;
  min-width: 5rem;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  padding: 0 1rem;
  border-radius: var(--radius-pill);
  font-size: var(--fs-small);
  font-weight: 600;
}

.segmented input:checked + span {
  background: var(--color-dark);
  color: var(--color-white);
}

.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--color-green-deep);
  outline-offset: 2px;
  border-radius: var(--radius-pill);
}

.swatch-group-label {
  margin: 0.6rem 0 0.25rem;
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.swatch {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.swatch input[type='radio'] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.swatch-dot {
  width: 2rem;
  height: 2rem;
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.swatch:hover .swatch-dot {
  transform: scale(1.1);
}

.swatch:has(input[type='radio']:checked) .swatch-dot {
  box-shadow: 0 0 0 2px var(--color-white), 0 0 0 4px var(--color-green-deep);
}

.swatch:has(input:focus-visible) {
  outline: 2px solid var(--color-green-deep);
  outline-offset: 1px;
}

.swatch-custom {
  grid-auto-flow: column;
  gap: 0.4rem;
  padding: 0 0.75rem 0 0.35rem;
  border: 2px solid var(--color-cream-2);
  font-size: var(--fs-small);
  font-weight: 600;
}

.swatch-custom.active {
  border-color: var(--color-green-deep);
  background: var(--color-cream);
}

.swatch-custom input[type='color'] {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .swatch-dot {
    transition: none;
  }

  .swatch:hover .swatch-dot {
    transform: none;
  }
}
