/*
Theme Name: Nos Terrains Constructibles
Theme URI: https://www.nosterrainsconstructibles.com
Author: Sophie
Description: Thème WordPress sur-mesure reprenant à l'identique le gabarit "Terrains disponibles" (charte Une Autre Agence : bleu marine, bleu ciel, ambre), avec carte interactive, adresses floutées et popup de compte client.
Version: 1.7
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: terrains-theme
*/

  /* =====================================================================
     Polices de la charte graphique — fichiers à déposer dans un dossier
     "fonts" placé À CÔTÉ de cette page sur votre serveur (même dossier
     public_html que le fichier html, LISTE_TERRAINS_PDFs, etc.)
     Les 9 fichiers .ttf correspondants vous sont fournis séparément.
     ===================================================================== */
  @font-face{
    font-family:"Lemonada";
    src:url("fonts/Lemonada-Light.ttf") format("truetype");
    font-weight:300;
    font-style:normal;
    font-display:swap;
  }
  @font-face{
    font-family:"Lemonada";
    src:url("fonts/Lemonada-Regular.ttf") format("truetype");
    font-weight:400;
    font-style:normal;
    font-display:swap;
  }
  @font-face{
    font-family:"Lemonada";
    src:url("fonts/Lemonada-Medium.ttf") format("truetype");
    font-weight:500;
    font-style:normal;
    font-display:swap;
  }
  @font-face{
    font-family:"Lemonada";
    src:url("fonts/Lemonada-SemiBold.ttf") format("truetype");
    font-weight:600;
    font-style:normal;
    font-display:swap;
  }
  @font-face{
    font-family:"Lemonada";
    src:url("fonts/Lemonada-Bold.ttf") format("truetype");
    font-weight:700;
    font-style:normal;
    font-display:swap;
  }
  @font-face{
    font-family:"Unna";
    src:url("fonts/Unna-Regular.ttf") format("truetype");
    font-weight:400;
    font-style:normal;
    font-display:swap;
  }
  @font-face{
    font-family:"Unna";
    src:url("fonts/Unna-Italic.ttf") format("truetype");
    font-weight:400;
    font-style:italic;
    font-display:swap;
  }
  @font-face{
    font-family:"Unna";
    src:url("fonts/Unna-Bold.ttf") format("truetype");
    font-weight:700;
    font-style:normal;
    font-display:swap;
  }
  @font-face{
    font-family:"Unna";
    src:url("fonts/Unna-BoldItalic.ttf") format("truetype");
    font-weight:700;
    font-style:italic;
    font-display:swap;
  }

  :root{
    /* Palette reprise du logo Une Autre Agence : bleu marine, bleu ciel, ambre */
    --ink:#2b3442;
    --ink-soft:#64758a;
    --paper:#f6f7f9;
    --card:#ffffff;
    --line:#e2e6ec;
    --accent:#465164;
    --accent-dark:#313a47;
    --accent-light:#6babd0;
    --amber:#fbb911;
    --radius:14px;
    --font-titres:"Lemonada", Georgia, serif;
    --font-texte:"Unna", Georgia, "Times New Roman", serif;
    --font-ui:"Kulim Park", "Segoe UI", Arial, sans-serif;
  }
  *{box-sizing:border-box;}
  body{
    margin:0;
    padding:0;
    background:var(--paper);
    color:var(--ink);
    font-family:var(--font-texte);
    line-height:1.5;
  }

  /* ===== En-tête : à personnaliser (nom d'agence, logo, coordonnées) ===== */
  header{
    background:var(--card);
    color:#fff;
    padding:24px 20px 0;
    text-align:center;
  }
  header .top-bar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    flex-wrap:wrap;
    gap:16px;
    max-width:920px;
    margin:0 auto 20px;
    text-align:left;
  }
  header .logo-wrap{
    display:inline-block;
    background:#fff;
    padding:16px 44px;
    border-radius:10px;
  }
  header .logo-wrap img{
    display:block;
    height:68px;
    width:auto;
  }
  header .header-actions{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
  }
  .btn-compte{
    display:inline-block;
    font-family:var(--font-ui);
    font-weight:600;
    font-size:.9rem;
    padding:10px 20px;
    border-radius:999px;
    text-decoration:none;
    cursor:pointer;
    border:2px solid var(--accent-light);
    transition:background .15s ease, color .15s ease;
    white-space:nowrap;
    margin:0;
    -webkit-appearance:none;
    appearance:none;
  }
  .btn-compte.btn-outline{
    background:#fff;
    color:var(--accent-light);
  }
  .btn-compte.btn-outline:hover{
    background:var(--accent-light);
    color:#fff;
  }
  .btn-compte.btn-solid{
    background:var(--accent-light);
    color:#fff;
  }
  .btn-compte.btn-solid:hover{
    background:var(--accent);
    border-color:var(--accent);
  }
  @media (max-width:640px){
    header .top-bar{ justify-content:center; text-align:center; }
  }
  header .titre-bloc{
    background:var(--accent-dark);
    margin:0 -20px;
    padding:20px 20px 26px;
    border-top:3px solid var(--amber);
    border-top-left-radius:var(--radius);
    border-top-right-radius:var(--radius);
  }
  header h1{
    margin:0 0 6px;
    font-family:var(--font-titres);
    font-size:1.8rem;
    font-weight:600;
    letter-spacing:.02em;
  }
  header p{
    margin:0;
    font-family:var(--font-ui);
    color:var(--accent-light);
    font-size:.95rem;
  }

  /* ===== Filtre par commune (généré automatiquement, voir le script en fin de page) ===== */
  .communes-filter{
    display:flex;
    flex-wrap:wrap;
    justify-content:center;
    gap:8px;
    margin-top:6px;
  }
  .communes-filter:empty{ display:none; }
  .commune-btn{
    font-family:var(--font-ui);
    font-size:.85rem;
    font-weight:600;
    color:#fff;
    background:rgba(255,255,255,.12);
    border:1px solid rgba(255,255,255,.35);
    padding:6px 14px;
    border-radius:999px;
    cursor:pointer;
    transition:background .15s ease, color .15s ease;
  }
  .commune-btn:hover{ background:rgba(255,255,255,.22); }
  .commune-btn.active{
    background:var(--amber);
    border-color:var(--amber);
    color:var(--accent-dark);
  }

  main{
    max-width:920px;
    margin:0 auto;
    padding:28px 16px 60px;
  }

  .carte-terrains-wrap{
    background:var(--card);
    border:1px solid var(--line);
    border-top:3px solid var(--amber);
    border-radius:var(--radius);
    overflow:hidden;
    margin-bottom:24px;
  }
  #carte-terrains{
    height:380px;
    width:100%;
    background:var(--paper); /* visible si la carte ne charge pas (pas de connexion internet) */
  }
  .marqueur-terrain{
    filter:drop-shadow(0 3px 4px rgba(43,52,66,.4));
    transition:transform .15s ease;
    transform-origin:50% 100%;
  }
  .marqueur-terrain:hover{ transform:scale(1.12); }
  .leaflet-popup-content{
    font-family:var(--font-ui);
    font-size:.85rem;
    color:var(--ink);
  }
  .leaflet-popup-content strong{
    font-family:var(--font-titres);
    color:var(--accent-dark);
    font-size:1rem;
  }
  @media (max-width:640px){
    #carte-terrains{ height:280px; }
  }

  .intro{
    color:var(--ink-soft);
    font-family:var(--font-ui);
    font-size:.95rem;
    margin:0 0 24px;
    text-align:center;
  }

  /* ===== Une "programme" = un secteur avec un ou plusieurs lots et un seul PDF de plans ===== */
  .programme{
    background:var(--card);
    border:1px solid var(--line);
    border-top:3px solid var(--amber);
    border-radius:var(--radius);
    margin-bottom:20px;
    overflow:hidden;
  }
  .programme-header{
    padding:18px 20px;
    border-bottom:1px solid var(--line);
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    justify-content:space-between;
    gap:12px;
  }
  .programme-header h2{
    margin:0 0 2px;
    font-family:var(--font-titres);
    font-size:1.25rem;
    font-weight:600;
  }
  .programme-header .localisation{
    margin:0;
    font-family:var(--font-ui);
    color:var(--ink-soft);
    font-size:1.05rem;
  }
  .localisation .adresse-verrou{
    display:none;
    font-size:.78rem;
    font-weight:600;
    color:var(--accent);
    font-family:var(--font-ui);
  }
  /* Adresse floutée tant que le visiteur n'est pas un client connecté (voir
     le script en fin de page, qui ajoute/retire la classe "connecte" sur
     <body> selon l'état de connexion). */
  body:not(.connecte) .localisation{ cursor:pointer; }
  body:not(.connecte) .localisation .adresse-texte{
    filter:blur(5px);
    user-select:none;
  }
  body:not(.connecte) .localisation .adresse-verrou{
    display:inline-block;
    margin-left:6px;
  }
  .btn-plan{
    display:inline-flex;
    align-items:center;
    gap:6px;
    background:var(--accent);
    color:#fff;
    text-decoration:none;
    font-family:var(--font-titres);
    font-size:.92rem;
    font-weight:600;
    padding:9px 14px;
    border-radius:999px;
    white-space:nowrap;
    transition:background .15s ease;
    border:none;
    cursor:pointer;
  }
  .btn-plan:hover{ background:var(--accent-dark); }

  /* ===== Les rubriques (Lot, Superficie, Prix...) s'affichent en ligne,
     côte à côte sur un même en-tête horizontal, chaque valeur dans une
     pastille arrondie façon étiquette, séparées par de fins traits
     verticaux. Le tableau occupe toujours 100% de la largeur disponible
     (jamais de défilement horizontal ni de débordement) : la police, les
     espacements et la taille des pastilles se réduisent en douceur avec
     la largeur de l'écran grâce à clamp()/vw, colonnes à largeur égale
     (table-layout:fixed) pour que rien ne pousse en dehors du cadre. ===== */
  table.lots{
    width:100%;
    table-layout:fixed;
    border-collapse:collapse;
    font-size:clamp(.62rem, 1.7vw + .3rem, 1.05rem);
  }
  table.lots th, table.lots td{
    text-align:center;
    padding:clamp(6px, 1.6vw, 14px) clamp(2px, .8vw, 14px);
    border-right:1px solid var(--line);
    overflow-wrap:break-word;
  }
  table.lots th:last-child, table.lots td:last-child{ border-right:none; }

  /* Largeur de chaque colonne : les colonnes à valeur courte (Lot, Zone
     PLU, Viabilisation) ou à icône seule (Plan, PLU) prennent moins de
     place, ce qui laisse plus de largeur aux colonnes qui en ont
     vraiment besoin (Prix, Superficie, Surface plancher) — évite que
     "167 000 €" ou "1288 m²" ne soient contraints à passer à la ligne.
     Un seul gabarit de tableau à 8 colonnes, commun à toutes les
     sections : Lot, Plan, Superficie, Prix, Surface plancher / emprise
     au sol, Zone PLU, PLU, Viabilisation. */
  table.lots th:nth-child(1),
  table.lots td:nth-child(1){ width:9%; }    /* Lot */
  table.lots th:nth-child(2),
  table.lots td:nth-child(2){ width:8%; }    /* Plan */
  table.lots th:nth-child(3),
  table.lots td:nth-child(3){ width:13%; }   /* Superficie */
  table.lots th:nth-child(4),
  table.lots td:nth-child(4){ width:14%; }   /* Prix */
  table.lots th:nth-child(5),
  table.lots td:nth-child(5){ width:21%; }   /* Surface plancher / emprise au sol */
  table.lots th:nth-child(6),
  table.lots td:nth-child(6){ width:9%; }    /* Zone PLU */
  table.lots th:nth-child(7),
  table.lots td:nth-child(7){ width:7%; }    /* PLU */
  table.lots th:nth-child(8),
  table.lots td:nth-child(8){ width:19%; }   /* Viabilisation */
  table.lots thead th{
    font-family:var(--font-ui);
    font-size:clamp(.56rem, .9vw + .3rem, .78rem);
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:.03em;
    color:var(--ink-soft);
    border-bottom:1px solid var(--line);
    line-height:1.25;
  }
  table.lots tbody tr:not(:last-child) td{
    border-bottom:1px solid var(--line);
  }

  /* Pastilles : chaque valeur est affichée dans une étiquette arrondie,
     plus facile à repérer d'un coup d'œil qu'un simple texte en ligne.
     Elles rétrécissent avec le texte du tableau et ne dépassent jamais
     de leur colonne (max-width:100%, retour à la ligne si nécessaire). */
  table.lots td .pill{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    max-width:100%;
    background:var(--paper);
    border-radius:999px;
    padding:clamp(4px, 1vw, 8px) clamp(6px, 1.6vw, 16px);
    font-weight:600;
    color:var(--ink);
    white-space:normal;
    overflow-wrap:break-word;
    line-height:1.2;
  }
  table.lots td .pill.pill-prix{
    background:#fdf1d0;
  }

  /* Bouton PLU : icône seule, ronde, dans sa propre colonne (séparée de
     la valeur de zone). Ouvre le document PLU de la commune (popup si
     non connecté, sinon lecteur PDF — voir le script en fin de page). */
  table.lots td.cell-plu{ padding-left:4px; padding-right:4px; }
  .btn-plu{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:clamp(26px, 6vw, 42px);
    height:clamp(26px, 6vw, 42px);
    border-radius:50%;
    background:var(--accent);
    color:#fff;
    border:none;
    font-size:clamp(.7rem, 2vw, 1.05rem);
    cursor:pointer;
    transition:background .15s ease;
  }
  .btn-plu:hover{ background:var(--accent-dark); }

  @media (max-width:640px){
    .programme-header{ padding:16px; }
    .btn-plan{ width:100%; justify-content:center; }
  }

  footer{
    text-align:center;
    font-family:var(--font-ui);
    color:var(--ink-soft);
    font-size:.8rem;
    padding:20px;
  }

  /* ===== Popup "Créer un compte / Connexion" (voir le script en fin de
     page) — s'ouvre automatiquement quand un visiteur non connecté clique
     sur une adresse floutée ou sur "Voir plans + photos". ===== */
  .modal-overlay{
    position:fixed;
    inset:0;
    background:rgba(43,52,66,.6);
    display:none;
    align-items:center;
    justify-content:center;
    padding:20px;
    z-index:1000;
  }
  .modal-overlay.ouvert{ display:flex; }
  .modal-box{
    background:var(--card);
    border-radius:var(--radius);
    border-top:4px solid var(--amber);
    max-width:420px;
    width:100%;
    padding:30px 26px 26px;
    position:relative;
    box-shadow:0 20px 60px rgba(0,0,0,.3);
  }
  .modal-close{
    position:absolute;
    top:12px;
    right:14px;
    background:none;
    border:none;
    font-size:1.4rem;
    line-height:1;
    cursor:pointer;
    color:var(--ink-soft);
  }
  .modal-box h2{
    font-family:var(--font-titres);
    color:var(--accent-dark);
    font-size:1.35rem;
    margin:0 0 6px;
  }
  .modal-box .modal-sous-titre{
    font-family:var(--font-ui);
    color:var(--ink-soft);
    font-size:.9rem;
    margin:0 0 18px;
  }
  .modal-tabs{
    display:flex;
    gap:8px;
    margin-bottom:18px;
  }
  .modal-tab{
    flex:1;
    padding:8px 10px;
    border:1px solid var(--line);
    background:var(--paper);
    border-radius:999px;
    font-family:var(--font-ui);
    font-size:.85rem;
    font-weight:700;
    cursor:pointer;
    color:var(--ink-soft);
  }
  .modal-tab.actif{
    background:var(--accent-light);
    border-color:var(--accent-light);
    color:#fff;
  }
  .modal-form{
    display:none;
    flex-direction:column;
    gap:10px;
  }
  .modal-form.actif{ display:flex; }
  .modal-form input{
    padding:11px 12px;
    border:1px solid var(--line);
    border-radius:8px;
    font-family:var(--font-ui);
    font-size:.95rem;
    color:var(--ink);
  }
  .modal-form button[type="submit"]{
    margin-top:4px;
    padding:11px;
    border:none;
    border-radius:999px;
    background:var(--accent-light);
    color:#fff;
    font-family:var(--font-ui);
    font-weight:700;
    font-size:.95rem;
    cursor:pointer;
    transition:background .15s ease;
  }
  .modal-form button[type="submit"]:hover{ background:var(--accent); }
  .modal-msg{
    font-family:var(--font-ui);
    font-size:.85rem;
    margin-top:12px;
    padding:9px 11px;
    border-radius:6px;
    display:none;
  }
  .modal-msg.ok{ display:block; background:#e6f4ea; color:#2e7d32; }
  .modal-msg.erreur{ display:block; background:#fdecea; color:#c62828; }
  .modal-connecte-info{
    font-family:var(--font-ui);
    font-size:.85rem;
    color:var(--ink-soft);
    text-align:center;
  }
  .modal-connecte-info button{
    margin-top:10px;
    background:none;
    border:1px solid var(--line);
    border-radius:999px;
    padding:8px 16px;
    font-family:var(--font-ui);
    font-size:.85rem;
    cursor:pointer;
    color:var(--ink);
  }

  /* ===== Popup de consultation PDF (plans + photos, ou document PLU) —
     même overlay que la popup de compte, mais une boîte quasi plein écran
     pour que le document reste lisible sans avoir à zoomer, fermable par
     la croix ou Échap. Un lien permet aussi de l'ouvrir dans un nouvel
     onglet (visionneuse PDF native du navigateur, plus confortable
     encore pour un document dense). ===== */
  #modal-pdf.modal-overlay{ padding:16px; }
  .modal-pdf-box{
    max-width:1200px;
    width:96vw;
    height:94vh;
    padding:48px 14px 14px;
    display:flex;
    flex-direction:column;
  }
  .modal-pdf-ouvrir{
    position:absolute;
    top:14px;
    right:54px;
    font-family:var(--font-ui);
    font-size:.8rem;
    font-weight:600;
    color:var(--accent);
    text-decoration:none;
    padding:7px 12px;
    border:1px solid var(--line);
    border-radius:999px;
    background:var(--paper);
    white-space:nowrap;
  }
  .modal-pdf-ouvrir:hover{ color:#fff; background:var(--accent); border-color:var(--accent); }
  .modal-pdf-box iframe{
    flex:1;
    width:100%;
    border:1px solid var(--line);
    border-radius:8px;
    background:#fff;
  }

  @media (max-width:640px){
    #modal-pdf.modal-overlay{ padding:0; }
    .modal-pdf-box{
      width:100vw;
      height:100vh;
      max-width:none;
      border-radius:0;
      padding:52px 8px 8px;
    }
    .modal-pdf-ouvrir{
      right:46px;
      font-size:.72rem;
      padding:6px 9px;
    }
  }

  /* ===== Popup "Documents" — liste des catégories de documents
     disponibles pour un lot (Plan, Photos, G1, Règlement, Autres).
     Reprend la boîte compacte de la popup de compte (.modal-box), avec
     une liste de boutons pleine largeur au lieu d'un formulaire. Choisir
     un document l'ouvre dans la popup de lecture PDF (voir le script en
     fin de page). ===== */
  .modal-docs-box{ max-width:380px; }
  #modal-docs-liste{
    display:flex;
    flex-direction:column;
    gap:8px;
  }
  .docs-item{
    display:flex;
    align-items:center;
    gap:10px;
    padding:11px 14px;
    border:1px solid var(--line);
    border-radius:8px;
    background:var(--paper);
    font-family:var(--font-ui);
    font-size:.95rem;
    font-weight:600;
    color:var(--ink);
    cursor:pointer;
    text-align:left;
    transition:background .15s ease, color .15s ease, border-color .15s ease;
  }
  .docs-item::before{ content:"📄"; }
  .docs-item:hover{ background:var(--accent-light); border-color:var(--accent-light); color:#fff; }
