/* =========================================================
   CorrectPro — Design system
   Concept: the DELF oral exam is a "tirage au sort" — you draw
   a numbered ticket and speak. Subject cards read as draw
   tickets (perforated stub + number), sessions read as exam
   folders, and the loader is a speech waveform instead of a
   generic spinner — because this whole app prepares people to
   talk.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root{
  --ink:#101B33;
  --paper:#F2F5FA;
  --card:#FFFFFF;
  --line:#DEE5EF;
  --text:#1E293B;
  --text-light:#5B6B85;

  --blue:#0091D8;
  --blue-dark:#0072AB;
  --blue-light:#E4F4FC;

  --green:#77B43F;
  --green-dark:#5E9430;
  --green-light:#EEF7E3;

  --gold:#F0B429;
  --gold-dark:#B9840A;
  --gold-light:#FCF1D6;

  --red:#D6483D;
  --red-light:#FBEAE8;

  --radius-lg:22px;
  --radius-md:14px;
  --radius-sm:9px;

  --shadow-sm:0 2px 10px rgba(16,27,51,.06);
  --shadow-md:0 12px 32px rgba(16,27,51,.09);
  --shadow-lg:0 24px 60px rgba(16,27,51,.16);

  --font-display:'Fraunces', Georgia, serif;
  --font-body:'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:'IBM Plex Mono', ui-monospace, monospace;
}

*{margin:0;padding:0;box-sizing:border-box;}

html{-webkit-font-smoothing:antialiased;}

body{
  font-family:var(--font-body);
  background:var(--paper);
  color:var(--text);
  line-height:1.5;
}

/* subtle paper grain so flat panels don't feel sterile */
body::before{
  content:'';
  position:fixed;inset:0;
  pointer-events:none;
  background-image:radial-gradient(rgba(16,27,51,.035) 1px, transparent 1px);
  background-size:3px 3px;
  opacity:.5;
  z-index:0;
}

a{color:inherit;}

:focus-visible{
  outline:3px solid var(--gold);
  outline-offset:2px;
  border-radius:4px;
}

@media (prefers-reduced-motion: reduce){
  *{animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important;}
}

/* ---------- layout ---------- */
.container{max-width:1080px;margin:0 auto;padding:2.5rem 1.75rem 5rem;position:relative;z-index:1;}

.top-bar{
  display:flex;align-items:center;justify-content:space-between;
  gap:1rem;flex-wrap:wrap;
  margin-bottom:2.25rem;
}
.back-btn{
  display:inline-flex;align-items:center;gap:.5rem;
  text-decoration:none;color:var(--text-light);font-weight:600;
  font-size:.92rem;padding:.5rem .9rem .5rem .5rem;
  border-radius:50px;transition:.2s;
}
.back-btn:hover{color:var(--blue-dark);background:var(--card);box-shadow:var(--shadow-sm);}
.back-btn i{font-size:.8rem;}

.page-heading{text-align:right;}
.page-kicker{
  font-family:var(--font-mono);font-size:.72rem;letter-spacing:.14em;
  color:var(--text-light);text-transform:uppercase;display:block;margin-bottom:.15rem;
}
.page-title{
  font-family:var(--font-display);font-weight:600;font-size:1.9rem;color:var(--ink);
}
.page-title .accent-blue{color:var(--blue-dark);}
.page-title .accent-green{color:var(--green-dark);}

/* ---------- buttons ---------- */
.btn{
  display:inline-flex;align-items:center;gap:.55rem;
  padding:.75rem 1.5rem;border:none;border-radius:50px;
  font-family:var(--font-body);font-size:.94rem;font-weight:700;
  cursor:pointer;transition:transform .15s ease, box-shadow .15s ease, background .15s ease;
  white-space:nowrap;
}
.btn:active{transform:translateY(1px);}
.btn:disabled{opacity:.5;cursor:not-allowed;transform:none;box-shadow:none;}

.btn-primary{background:var(--ink);color:#fff;}
.btn-primary:hover:not(:disabled){background:#0A1428;box-shadow:var(--shadow-md);}

.btn-accent-blue{background:var(--blue);color:#fff;}
.btn-accent-blue:hover:not(:disabled){background:var(--blue-dark);box-shadow:0 10px 26px rgba(0,145,216,.35);}

.btn-accent-green{background:var(--green);color:#fff;}
.btn-accent-green:hover:not(:disabled){background:var(--green-dark);box-shadow:0 10px 26px rgba(119,180,63,.35);}

.btn-outline{background:transparent;border:2px solid var(--line);color:var(--text);}
.btn-outline:hover:not(:disabled){border-color:var(--ink);color:var(--ink);}

.btn-icon{
  width:38px;height:38px;border-radius:50%;border:none;background:transparent;
  color:var(--text-light);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;
  transition:.15s;
}
.btn-icon:hover{background:var(--red-light);color:var(--red);}

/* ---------- paper bar (document name + serie) ---------- */
.paper-bar{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-sm);
  padding:1.1rem 1.6rem;
  margin-bottom:2rem;
  display:flex;align-items:flex-start;gap:1rem;
}
.paper-bar .icon-wrap{
  width:42px;height:42px;border-radius:50%;
  background:var(--gold-light);color:var(--gold-dark);
  display:flex;align-items:center;justify-content:center;flex-shrink:0;font-size:1.05rem;
  margin-top:.1rem;
}
.paper-fields{flex:1;display:flex;flex-wrap:wrap;gap:1.25rem 1.5rem;}
.paper-field{display:flex;flex-direction:column;}
.paper-field-name{flex:2 1 240px;}
.paper-field-month{flex:1 1 140px;}
.paper-field-year{flex:1 1 90px;}
.paper-bar label{display:block;font-family:var(--font-mono);font-size:.68rem;letter-spacing:.1em;color:var(--text-light);text-transform:uppercase;margin-bottom:.15rem;}
.paper-bar input,
.paper-bar select{
  width:100%;border:none;outline:none;background:transparent;
  font-family:var(--font-display);font-size:1.15rem;color:var(--ink);
  border-bottom:2px solid var(--line);padding-bottom:.3rem;transition:.2s;
  appearance:none;-webkit-appearance:none;border-radius:0;cursor:pointer;
}
.paper-bar input{cursor:text;}
.paper-bar input:focus,
.paper-bar select:focus{border-bottom-color:var(--blue);}
.paper-bar input::placeholder{color:#A9B4C6;font-family:var(--font-body);font-weight:400;}
.paper-bar select:invalid{color:#A9B4C6;}

@media (max-width:640px){
  .paper-field-name{flex-basis:100%;}
}

/* ---------- sessions (accordion) ---------- */
.accordion{display:flex;flex-direction:column;gap:1.1rem;}

.session{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-sm);
  overflow:hidden;
}
.session-header{
  padding:1.15rem 1.6rem;
  display:flex;align-items:center;justify-content:space-between;gap:1rem;
  cursor:pointer;user-select:none;
}
.session-header:hover{background:#FAFBFD;}
.session-id{
  display:flex;align-items:center;gap:.85rem;
}
.session-badge{
  font-family:var(--font-mono);font-weight:600;font-size:.78rem;letter-spacing:.06em;
  color:var(--blue-dark);background:var(--blue-light);
  padding:.35rem .65rem;border-radius:7px;
}
.session-title{font-family:var(--font-display);font-weight:600;font-size:1.15rem;color:var(--ink);}
.session-progress{font-family:var(--font-mono);font-size:.78rem;color:var(--text-light);}
.session-progress.complete{color:var(--green-dark);}
.session-controls{display:flex;align-items:center;gap:.35rem;}
.chevron{transition:transform .3s ease;color:var(--text-light);}
.session.open .chevron{transform:rotate(180deg);}
.session-body{max-height:0;overflow:hidden;transition:max-height .35s ease;}
.session.open .session-body{max-height:none;}
.session-body-inner{padding:.3rem 1.6rem 1.6rem;}

.session-actions{
  margin-top:1.1rem;display:flex;align-items:center;gap:1.1rem;flex-wrap:wrap;
}

/* speech waveform loader */
.waveform-loading{display:none;align-items:center;gap:.6rem;color:var(--text-light);font-size:.88rem;font-weight:600;}
.waveform-loading.active{display:inline-flex;}
.waveform-bars{display:inline-flex;align-items:center;gap:3px;height:18px;}
.waveform-bars span{
  width:3px;background:var(--blue);border-radius:2px;
  animation:wave 1s ease-in-out infinite;
}
.waveform-bars span:nth-child(1){height:6px;animation-delay:0s;}
.waveform-bars span:nth-child(2){height:14px;animation-delay:.12s;}
.waveform-bars span:nth-child(3){height:18px;animation-delay:.24s;}
.waveform-bars span:nth-child(4){height:10px;animation-delay:.36s;}
.waveform-bars span:nth-child(5){height:15px;animation-delay:.48s;}
@keyframes wave{0%,100%{transform:scaleY(.4);}50%{transform:scaleY(1);}}

/* ---------- draw tickets (subjects) ---------- */
.ticket-list{display:flex;flex-direction:column;gap:1.35rem;margin-top:.5rem;}

.ticket{
  position:relative;
  display:flex;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-sm);
}
.ticket-notch{
  position:absolute;left:-9px;width:18px;height:18px;border-radius:50%;
  background:var(--paper);border:1px solid var(--line);z-index:2;
}
.ticket-notch.top{top:-9px;}
.ticket-notch.bottom{bottom:-9px;}

.ticket-stub{
  width:88px;flex-shrink:0;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.3rem;
  border-right:2px dashed var(--line);
  padding:1rem .5rem;
  background:linear-gradient(180deg, var(--blue-light) 0%, transparent 85%);
  border-radius:var(--radius-md) 0 0 var(--radius-md);
}
.stub-label{font-family:var(--font-mono);font-size:.6rem;letter-spacing:.14em;color:var(--text-light);text-transform:uppercase;}
.stub-num{font-family:var(--font-mono);font-weight:600;font-size:1.55rem;color:var(--blue-dark);}

.ticket-body{flex:1;padding:1.15rem 1.35rem;min-width:0;}

.ticket textarea{
  width:100%;border:1px solid var(--line);border-radius:var(--radius-sm);
  padding:.7rem .85rem;font-family:var(--font-body);font-size:.96rem;color:var(--text);
  resize:vertical;background:#FCFDFE;transition:.15s;
}
.ticket textarea:focus{outline:none;border-color:var(--blue);background:#fff;box-shadow:0 0 0 3px var(--blue-light);}

.ticket-meta{margin-top:.65rem;display:flex;align-items:center;gap:.6rem;}
.ticket-meta label{font-family:var(--font-mono);font-size:.68rem;letter-spacing:.08em;color:var(--text-light);text-transform:uppercase;}
.ticket-meta select{
  padding:.4rem .7rem;border:1px solid var(--line);border-radius:7px;
  background:#fff;font-family:var(--font-body);font-size:.86rem;color:var(--text);cursor:pointer;
}

.correction{
  margin-top:.9rem;padding:.95rem 1.1rem;background:var(--green-light);
  border-radius:var(--radius-sm);border-left:4px solid var(--green);
  display:none;position:relative;
}
.correction.visible{display:block;animation:reveal .3s ease;}
@keyframes reveal{from{opacity:0;transform:translateY(4px);}to{opacity:1;transform:translateY(0);}}
.correction h4{
  font-family:var(--font-mono);font-size:.68rem;letter-spacing:.1em;text-transform:uppercase;
  color:var(--green-dark);margin-bottom:.5rem;
}
.correction-text{white-space:pre-wrap;font-size:.92rem;color:var(--text);line-height:1.65;}
.correction-actions{position:absolute;top:.7rem;right:.7rem;display:flex;gap:.4rem;}
.copy-btn,.regen-btn{
  background:#fff;border:1px solid var(--line);
  border-radius:7px;width:30px;height:30px;color:var(--text-light);cursor:pointer;
  display:flex;align-items:center;justify-content:center;transition:.15s;
}
.copy-btn:hover{color:var(--green-dark);border-color:var(--green);}
.regen-btn:hover{color:var(--blue-dark);border-color:var(--blue);}
.regen-btn:disabled{opacity:.5;cursor:not-allowed;}
.regen-btn i.fa-spin{animation:spin 1s linear infinite;}
@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}

/* ---------- pronunciation-practice audio (Tache 3) ---------- */
.audio-player{
  margin-top:.7rem;padding:.7rem .9rem;background:#fff;
  border:1px solid var(--line);border-radius:var(--radius-sm);
  display:none;align-items:center;gap:.7rem;flex-wrap:wrap;
}
.audio-player.visible{display:flex;animation:reveal .3s ease;}
.audio-voice-badge{
  font-family:var(--font-mono);font-size:.68rem;letter-spacing:.06em;text-transform:uppercase;
  color:var(--blue-dark);background:var(--blue-light);padding:.3rem .6rem;border-radius:20px;
  flex-shrink:0;display:inline-flex;align-items:center;gap:.35rem;
}
.audio-player audio{flex:1;min-width:180px;height:36px;}
.audio-download{
  flex-shrink:0;width:32px;height:32px;border-radius:7px;border:1px solid var(--line);
  color:var(--text-light);display:flex;align-items:center;justify-content:center;
  text-decoration:none;transition:.15s;
}
.audio-download:hover{color:var(--blue-dark);border-color:var(--blue);}
.audio-regen-btn{
  flex-shrink:0;width:32px;height:32px;border-radius:7px;border:1px solid var(--line);
  color:var(--text-light);background:#fff;display:flex;align-items:center;justify-content:center;
  cursor:pointer;transition:.15s;
}
.audio-regen-btn:hover{color:var(--blue-dark);border-color:var(--blue);}
.audio-regen-btn:disabled{opacity:.5;cursor:not-allowed;}
.audio-regen-btn i.fa-spin{animation:spin 1s linear infinite;}


/* tache3 accent uses blue instead of green for the correction color */
.theme-blue .correction{background:var(--blue-light);border-left-color:var(--blue);}
.theme-blue .correction h4{color:var(--blue-dark);}
.theme-blue .waveform-bars span{background:var(--green);}

/* ---------- bottom bar / toast ---------- */
.bottom-bar{margin-top:2.25rem;display:flex;justify-content:flex-end;gap:1rem;flex-wrap:wrap;}

.toast{
  position:fixed;bottom:1.75rem;right:1.75rem;left:1.75rem;
  max-width:420px;margin-left:auto;
  max-height:min(60vh, 320px);overflow-y:auto;
  background:var(--ink);color:#fff;padding:.95rem 1.5rem;border-radius:12px;
  box-shadow:var(--shadow-lg);font-weight:600;font-size:.92rem;z-index:999;
  opacity:0;transform:translateY(16px);transition:.3s ease;
  display:flex;align-items:flex-start;gap:.6rem;
}
.toast span{overflow-wrap:anywhere;}
.toast i{flex-shrink:0;margin-top:.15rem;}
.toast.show{opacity:1;transform:translateY(0);}
.toast.success{background:var(--green-dark);}
.toast.error{background:var(--red);}

/* persistent reminder while there are uncompiled corrections. Unlike the
   toast, this stays on screen (it's not tied to the native beforeunload
   dialog, which browsers reserve exclusively for themselves) — it just
   keeps the "compile before you go" message visibly present the whole
   time so it's much harder to forget. */
.unsaved-banner{
  position:fixed;bottom:1.75rem;left:1.75rem;max-width:360px;z-index:998;
  background:var(--gold-light);border:1px solid var(--gold);color:#7A5B06;
  padding:.85rem 1rem;border-radius:12px;box-shadow:var(--shadow-md);
  display:none;align-items:flex-start;gap:.65rem;font-size:.86rem;font-weight:600;line-height:1.5;
}
.unsaved-banner.visible{display:flex;animation:reveal .3s ease;}
.unsaved-banner i.fa-triangle-exclamation{color:var(--gold-dark);margin-top:.15rem;flex-shrink:0;}
.unsaved-banner span{flex:1;}
.unsaved-banner-close{
  background:none;border:none;color:#7A5B06;cursor:pointer;flex-shrink:0;
  padding:0;opacity:.55;font-size:.95rem;line-height:1;transition:.15s;
}
.unsaved-banner-close:hover{opacity:1;}

@media (max-width:640px){
  .unsaved-banner{left:1rem;right:1rem;max-width:none;bottom:auto;top:1rem;}
}

/* ---------- empty state ---------- */
.empty-state{
  background:var(--card);border:1.5px dashed var(--line);border-radius:var(--radius-lg);
  padding:3rem 2rem;text-align:center;color:var(--text-light);
}
.empty-state i{font-size:1.8rem;color:var(--blue);margin-bottom:.75rem;display:block;}
.empty-state p{font-size:.95rem;}

/* ---------- full-page generation overlay ---------- */
.page-loader{
  position:fixed;inset:0;z-index:1000;
  background:rgba(16,27,51,.6);
  backdrop-filter:blur(3px);
  display:none;align-items:center;justify-content:center;flex-direction:column;gap:1.1rem;
  text-align:center;padding:2rem;
}
.page-loader.active{display:flex;}
.page-loader .waveform-bars{height:36px;gap:5px;}
.page-loader .waveform-bars span{width:5px;background:#fff;}
.page-loader-title{font-family:var(--font-display);font-weight:600;font-size:1.35rem;color:#fff;}
.page-loader-text{font-family:var(--font-body);font-size:.95rem;color:rgba(255,255,255,.82);max-width:380px;line-height:1.6;}

/* ---------- confirmation modal (leave-page warning) ---------- */
.modal-overlay{
  position:fixed;inset:0;z-index:1100;
  background:rgba(16,27,51,.55);
  display:none;align-items:center;justify-content:center;padding:1.5rem;
}
.modal-overlay.visible{display:flex;animation:reveal .2s ease;}
.modal-card{
  background:var(--card);border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);
  padding:2rem 1.85rem;max-width:400px;width:100%;text-align:center;
}
.modal-card i.fa-triangle-exclamation{font-size:1.6rem;color:var(--gold-dark);margin-bottom:.9rem;}
.modal-question{font-family:var(--font-body);font-size:1rem;color:var(--text);line-height:1.65;margin-bottom:1.6rem;}
.modal-actions{display:flex;gap:.75rem;justify-content:center;}
.modal-actions .btn{flex:1;justify-content:center;}

@media (max-width:640px){

  .container{padding:1.5rem 1.1rem 4rem;}
  .top-bar{flex-direction:column;align-items:flex-start;}
  .page-heading{text-align:left;}
  .ticket{flex-direction:column;}
  .ticket-stub{
    width:100%;flex-direction:row;justify-content:flex-start;gap:.6rem;
    border-right:none;border-bottom:2px dashed var(--line);
    border-radius:var(--radius-md) var(--radius-md) 0 0;padding:.6rem 1rem;
  }
  .bottom-bar{justify-content:stretch;}
  .bottom-bar .btn{flex:1;justify-content:center;}
}