/* =========================================================
   Appreciation Certificate Generator - Styles
   ========================================================= */

/* ---------- Theme colors (change these to re-theme the app) ---------- */
:root {
  --navy: #1b2a4a;
  --navy-light: #2c3e66;
  --gold: #b8913a;
  --gold-light: #d9b968;
  --gold-pale: #f4ead2;
  --gray-900: #1f2430;
  --gray-600: #5b6272;
  --gray-300: #d5d9e0;
  --gray-100: #f3f4f7;
  --white: #ffffff;
  --danger: #c0392b;

  --radius: 12px;
  --shadow: 0 10px 30px rgba(27, 42, 74, 0.12);

  --font-serif: "Playfair Display", Georgia, serif;
  --font-display: "Cinzel", "Times New Roman", serif;
  --font-script: "Great Vibes", cursive;
  --font-sans: "Inter", "Segoe UI", Arial, sans-serif;

  /* Fixed certificate size: A4 landscape at 96 DPI */
  --cert-w: 1123px;
  --cert-h: 794px;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--gray-900);
  background: linear-gradient(160deg, #eef1f6 0%, #e4e8f0 100%);
  min-height: 100vh;
}

/* ---------- Header / Footer ---------- */
.app-header {
  text-align: center;
  padding: 40px 20px 24px;
}

.app-header h1 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  color: var(--navy);
}

.app-header p {
  margin: 0;
  color: var(--gray-600);
}

.app-footer {
  text-align: center;
  padding: 24px;
  color: var(--gray-600);
  font-size: 0.85rem;
}

/* ---------- Layout: form on the left, preview on the right ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  align-items: start;
}

.panel {
  min-width: 0;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel h2 {
  margin: 0 0 20px;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--navy);
}

/* ---------- Form ---------- */
.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-900);
}

.req {
  color: var(--danger);
}

.optional {
  font-weight: 400;
  color: var(--gray-600);
}

input[type="text"],
input[type="date"],
textarea {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: var(--gray-100);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(184, 145, 58, 0.18);
}

input.invalid,
textarea.invalid {
  border-color: var(--danger);
}

/* Custom file upload box */
.file-drop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 2px dashed var(--gray-300);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  color: var(--gray-600);
  transition: border-color 0.2s, background 0.2s;
}

.file-drop:hover {
  border-color: var(--gold);
  background: var(--gold-pale);
}

.logo-thumb {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--white);
}

.link-btn {
  align-self: flex-start;
  margin-top: 6px;
  padding: 0;
  border: none;
  background: none;
  color: var(--danger);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.form-error {
  min-height: 1.2em;
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 0.85rem;
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s, opacity 0.2s;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn-primary {
  width: 100%;
  background: var(--navy);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--navy-light);
}

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

.btn-gold:hover:not(:disabled) {
  background: #a27e2f;
}

.btn-outline {
  background: transparent;
  color: var(--navy);
  border-color: var(--navy);
}

.btn-outline:hover:not(:disabled) {
  background: var(--gray-100);
}

/* ---------- Preview panel ---------- */
.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.preview-head h2 {
  margin: 0;
}

.download-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* The stage centers the certificate; its height is set by script.js */
.cert-stage {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

/* The scaler shrinks the fixed-size certificate to fit the stage */
.cert-scaler {
  width: var(--cert-w);
  height: var(--cert-h);
  transform-origin: top center;
  flex-shrink: 0;
}

.status-msg {
  text-align: center;
  color: var(--gray-600);
  font-size: 0.9rem;
  margin: 16px 0 0;
}

/* =========================================================
   CERTIFICATE DESIGN
   Uses fixed pixel sizes so the exported PDF/image always
   looks identical, no matter the screen size.
   ========================================================= */
.certificate {
  width: var(--cert-w);
  height: var(--cert-h);
  padding: 22px;
  background: var(--navy);
  font-family: var(--font-sans);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.cert-border-outer {
  height: 100%;
  padding: 8px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-light));
}

.cert-border-inner {
  position: relative;
  height: 100%;
  background:
    radial-gradient(circle at 50% 40%, #ffffff 0%, #fdfaf2 60%, #f6efdc 100%);
  border: 1px solid var(--gold);
  outline: 2px solid var(--gold-pale);
  outline-offset: -14px;
}

/* Decorative L-shaped gold corners */
.corner {
  position: absolute;
  width: 70px;
  height: 70px;
  border: 3px solid var(--gold);
}

.corner.tl { top: 24px;    left: 24px;  border-right: none; border-bottom: none; }
.corner.tr { top: 24px;    right: 24px; border-left: none;  border-bottom: none; }
.corner.bl { bottom: 24px; left: 24px;  border-right: none; border-top: none; }
.corner.br { bottom: 24px; right: 24px; border-left: none;  border-top: none; }

.cert-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 44px 110px 40px;
}

.cert-logo-wrap {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.cert-logo {
  max-height: 84px;
  max-width: 220px;
  object-fit: contain;
}

.cert-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 58px;
  font-weight: 700;
  letter-spacing: 10px;
  text-transform: uppercase;
  color: var(--navy);
  line-height: 1.1;
}

.cert-subtitle {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 8px;
  text-transform: uppercase;
  color: var(--gold);
}

.cert-presented {
  margin: 28px 0 4px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 19px;
  color: var(--gray-600);
}

.cert-name {
  margin: 0;
  font-family: var(--font-script);
  font-size: 84px;
  line-height: 1.15;
  color: var(--navy);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.name-rule {
  width: 460px;
  height: 2px;
  margin: 2px 0 16px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.cert-reason {
  margin: 0;
  max-width: 720px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--gray-900);
}

/* Footer: date | seal | signature */
.cert-footer {
  margin-top: auto;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.sign-block {
  width: 260px;
  text-align: center;
}

.sign-value {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--navy);
  min-height: 30px;
}

.sign-value.signature {
  font-family: var(--font-script);
  font-size: 34px;
  line-height: 1;
}

.sign-line {
  height: 1px;
  background: var(--gray-900);
}

.sign-label {
  margin: 8px 0 0;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gray-600);
}

/* Gold seal built purely with CSS */
.seal {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  padding: 6px;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 60%, #8f6e27);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.seal-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--white);
}

.seal-inner span {
  font-size: 34px;
  line-height: 1;
}

.seal-inner small {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-panel {
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
  }
}

@media (max-width: 480px) {
  .panel {
    padding: 18px;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .preview-head {
    flex-direction: column;
    align-items: stretch;
  }

  .download-actions .btn {
    flex: 1;
  }
}
