/**
 * Plugin Name: Text Onto Image
 * Description: Front-end styles for the text-onto-image shortcode (templates, preview, form).
 * Version: 1.0.0
 * Author: Your Name
 * License: GPLv2 or later
 */

@font-face {
  font-family: "Seeds Careem";
  src:
    url("../fonts/seeds/Seeds_for_Gaza_beta1-regular.woff2") format("woff2"),
    url("../fonts/seeds/Seeds_for_Gaza_beta1-regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Careem Sans";
  src:
    url("../fonts/careem/CareemSans-Light.woff2") format("woff2"),
    url("../fonts/careem/CareemSans-Light.woff") format("woff");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

/* Light (mapped to regular file if no true light provided) */
@font-face {
  font-family: "Seeds Careem";
  src:
    url("../fonts/seeds/Seeds_for_Gaza_beta1-regular.woff2") format("woff2"),
    url("../fonts/seeds/Seeds_for_Gaza_beta1-regular.woff") format("woff");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Seeds Careem";
  src:
    url("../fonts/seeds/Seeds_for_Gaza_beta1-Bold.woff2") format("woff2"),
    url("../fonts/seeds/Seeds_for_Gaza_beta1-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

.toi-wrap {
  --toi-green: #00d45a;
  --toi-green-dark: #053b1d;
  --toi-ink: rgba(0, 0, 0, 0.88);
  --toi-muted: rgba(0, 0, 0, 0.62);
  --toi-border: rgba(0, 0, 0, 0.12);
  --toi-cards-max: 466px; /* templates 10% smaller again (was 518px) */

  font-family: "Careem Sans", Helvetica, Arial, sans-serif;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 24px 24px 0;
  text-align: left;
  overflow: hidden; /* prevent plugin from extending on scroll */
}

.toi-wrap,
.toi-wrap * {
  box-sizing: border-box;
}

.toi-wrap a {
  color: inherit;
}

.toi-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.toi-layout {
  display: grid;
  grid-template-columns: 60% 40%;
  gap: 16px;
  align-items: start;
  min-height: 0; /* prevent grid from growing on scroll */
}

/* Stack layout at 1199px and below – phone max 450px, at top; form stacks */
@media (max-width: 1199px) {
  #toi-step2-label {
    scroll-margin-top: 90px; /* clear 90px sticky header so Step 2 isn’t hidden */
  }

  .toi-layout {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .toi-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
    height: auto;
    margin-bottom: 12px;
  }

  .toi-phone {
    width: min(450px, 100%);
    max-width: 450px;
    aspect-ratio: 360 / 600; /* 3:5, 600px height at 360px width */
    height: auto;
    position: relative;
    margin: 0 auto 20px;
    transform: none;
  }

  .toi-left .toi-bottom {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
  }

  .toi-left .toi-bottom-col:last-child {
    flex: 0 0 auto;
  }

  .toi-left .toi-bottom-col {
    width: 100%;
  }

  .toi-templates,
  .toi-bottom {
    max-width: 100%;
  }

  /* Hide desktop download button; show mobile button under phone */
  .toi-left .toi-bottom .toi-bottom-col:last-child {
    display: none;
  }

  .toi-download-mobile-wrap {
    display: flex;
    flex-direction: column;
    gap: 11px;
    margin-top: 30px;
    margin-bottom: 0;
    text-align: left;
    width: min(450px, 100%);
    margin-left: auto;
    margin-right: auto;
  }

  .toi-download-mobile-wrap .toi-step {
    margin: 0;
  }

  .toi-right {
    margin-bottom: 20px;
  }

  .toi-download-mobile-wrap .toi-download {
    width: 100%;
  }
}

/* Mobile download button: only show at 1199px and below */
.toi-left {
  min-width: 0;
}

.toi-right {
  display: flex;
  justify-content: flex-end; /* push phone down */
  align-items: flex-start; /* align with title */
  min-height: 0; /* prevent stretch that can extend on scroll */
}

.toi-titleblock {
  margin-bottom: 9px;
}

.toi-title {
  margin: 0 0 12px;
  font-family: "Careem Sans", "Seeds Careem", Helvetica, Arial, sans-serif;
  font-weight: 300; /* light */
  letter-spacing: -0.01em;
  line-height: 1.0;
  font-size: 50px;
  color: var(--toi-green-dark);
}

.toi-copy {
  margin: 0 0 16px;
  font-family: "Careem Sans", "Seeds Careem", Helvetica, Arial, sans-serif;
  font-weight: 300; /* light */
  font-size: 22px;
  line-height: 1.25;
  color: var(--toi-green-dark);
  max-width: 720px;
}

/* 1199px and down: smaller title and subtitle so they respond properly */
@media (max-width: 1199px) {
  .toi-wrap .toi-title {
    font-size: 30px;
  }

  .toi-wrap .toi-copy {
    font-size: 20px;
  }
}

.toi-step {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 24px;
  font-size: 14px;
  color: var(--toi-ink);
  flex-wrap: nowrap;
}

.toi-step-num {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #00E784;
  color: #000;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
}

.toi-step-text {
  font-family: "Careem Sans", "Seeds Careem", Helvetica, Arial, sans-serif;
  font-weight: 300;
  font-size: 15px;
  line-height: 1.15;
  white-space: nowrap;
}

.toi-templates {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  justify-items: start;
  margin: 0 0 40px;
  width: 100%;
  max-width: var(--toi-cards-max);
}

.toi-template {
  cursor: pointer;
  display: grid;
  gap: 8px;
  justify-items: start;
  user-select: none;
}

.toi-template-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toi-template-img {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  /* Crop down to avoid top text in templates */
  object-position: center 78%;
  border-radius: 16px;
  display: block;
  /* Keep layout stable: border is always 4px (transparent until selected). */
  border: 4px solid transparent; /* only visible when selected */
  box-shadow: none;
  opacity: 0.7; /* unselected ~70% */
  transition: border-color 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

/* Template-specific crop tweaks (avoid top writing) */
.toi-template-img[data-toi-template-id="1"] {
  object-position: center 82%;
}

.toi-template-img[data-toi-template-id="2"],
.toi-template-img[data-toi-template-id="3"] {
  object-position: center 78%;
}

.toi-template.is-selected .toi-template-img {
  border-color: rgba(0, 0, 0, 0.88);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.10);
  opacity: 1;
  border-radius: 16px; /* keep rounded corners when selected */
}

.toi-template:not(.is-selected) .toi-template-img {
  filter: saturate(0.92);
}

.toi-template-label {
  font-size: 12px;
  text-transform: lowercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
  font-weight: 700;
}

.toi-bottom {
  display: flex;
  flex-direction: row;
  gap: 26px;
  align-items: flex-end;
  margin-top: 10px;
  width: 100%;
  max-width: calc(var(--toi-cards-max) * 1.15);
}

.toi-bottom-col {
  display: flex;
  flex-direction: column;
  gap: 11px; /* label -> control */
  min-width: 0;
}

.toi-bottom-col:first-child {
  flex: 1 1 auto;
}

.toi-bottom-col:last-child {
  flex: 0 0 220px;
}

.toi-bottom-col .toi-step {
  margin: 0;
}

/* Above 1200px: keep step numbers and text same size; no reduction until mobile */

/* Form uses .toi-bottom-col */
.toi-input {
  width: 100%;
  height: 56px;
  padding: 5px 30px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #F2F2F2;
  outline: none;
  font-size: 18px;
  color: #000000;
}

.toi-download {
  width: 100%;
  height: 56px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: #00493E;
  color: #00E784;
  font-weight: 700;
  font-size: 16px;
}

.toi-download:hover {
  filter: brightness(1.05);
}

.toi-error {
  color: #b00020;
  font-size: 13px;
  min-height: 18px;
  margin-top: 12px;
}

.toi-phone {
  width: 100%;
  max-width: 450px;
  border: 8px solid #111;
  border-bottom: none;
  border-radius: 45px 45px 0 0; /* rounded top only, square bottom */
  padding: 0;
  background: #111; /* no white gap if image ever doesn't cover */
  overflow: hidden;
  box-sizing: border-box;
  transform: none;
  aspect-ratio: 360 / 600; /* 3:5, 600px height at 360px width */
  height: auto;
  position: relative;
}

/* Desktop (1200px+): smaller phone, consistent step size, step text can wrap */
@media (min-width: 1200px) {
  .toi-phone {
    max-width: 360px;
  }

  .toi-step-text {
    white-space: normal;
  }

  .toi-download-mobile-wrap {
    display: none;
  }
}

.toi-preview-img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 0;
  background: transparent;
  object-fit: cover;
  object-position: center center;
}

/* Fill phone frame with no white gap: absolute so image always covers content box */
.toi-phone .toi-preview-img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

/* Mobile: templates on top, big preview bottom – same phone size/cut-off */
@media (max-width: 980px) {
  .toi-wrap {
    padding: 24px 24px 0;
  }

  .toi-step-num {
    width: 27px;
    height: 27px;
    font-size: 13px;
  }

  .toi-step-text {
    font-size: 13px; /* smaller on mobile */
  }

  .toi-input,
  .toi-download {
    font-size: 14px;
  }

  .toi-layout {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .toi-right {
    justify-items: stretch;
    display: block;
    position: relative;
    overflow: hidden;
    height: auto;
  }

  .toi-phone {
    margin-top: 0;
    width: min(450px, 100%);
    max-width: 450px;
    aspect-ratio: 360 / 600; /* 3:5, 600px height at 360px width */
    height: auto;
    position: relative;
    margin-left: auto;
    margin-right: auto;
    transform: none;
  }

  .toi-templates {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }

  .toi-template-img {
    max-width: 100%;
  }
}


/* Small mobile: stack form; phone max 450px, at top */
@media (max-width: 500px) {
  .toi-bottom {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
  }

  .toi-bottom-col:last-child {
    flex: 0 0 auto;
  }

  .toi-right {
    height: auto;
  }

  .toi-phone {
    width: min(450px, 100%);
    max-width: 450px;
    aspect-ratio: 360 / 600; /* 3:5, 600px height at 360px width */
    height: auto;
    position: relative;
  }
}
