/* =====================================================
   TipsByCountry.com — Main Stylesheet
   Fonts: DM Serif Display (headings) + DM Sans (body)
   Mobile-first, fast-loading, SEO-friendly
   ===================================================== */

/* Fix: Chrome on Windows does not support flag emojis natively.
   Twemoji Country Flags font provides them cross-browser. */
@font-face {
  font-family: "Twemoji Country Flags";
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067,
                 U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  src: url("https://cdn.jsdelivr.net/npm/twemoji-country-flags@1.0.0/vendor/twemoji-country-flags.woff2") format("woff2");
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --tbc-green:       #1a6b4a;
  --tbc-green-light: #e8f5ee;
  --tbc-green-mid:   #2d8a60;
  --tbc-gold:        #c9922a;
  --tbc-gold-light:  #fdf3e3;
  --tbc-dark:        #1a1f1c;
  --tbc-mid:         #4a5550;
  --tbc-soft:        #7a8a82;
  --tbc-border:      #dde8e2;
  --tbc-bg:          #f7faf8;
  --tbc-white:       #ffffff;
  --tbc-error:       #c0392b;
  --tbc-warn-bg:     #fff8e1;
  --tbc-warn-border: #f0c040;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.09);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-flags:   'Twemoji Country Flags', system-ui, sans-serif;
  --transition: 0.18s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--tbc-dark);
  background: var(--tbc-bg);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--tbc-green); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font-body); border: none; background: none; }

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

/* ===== CONTAINER ===== */
.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== HEADER ===== */
.site-header {
  background: var(--tbc-white);
  border-bottom: 1px solid var(--tbc-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.logo-icon { font-size: 22px; }

.logo-text {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--tbc-dark);
  letter-spacing: -0.3px;
}

.logo-text em {
  font-style: italic;
  color: var(--tbc-green);
}

.main-nav { display: flex; gap: 4px; }

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--tbc-mid);
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: var(--tbc-green-light);
  color: var(--tbc-green);
  text-decoration: none;
}

/* ===== HERO ===== */
.hero {
  background: linear-gradient(135deg, var(--tbc-green) 0%, var(--tbc-green-mid) 100%);
  padding: 48px 0 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -40px; left: -40px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  pointer-events: none;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 46px);
  color: var(--tbc-white);
  line-height: 1.15;
  margin-bottom: 12px;
  position: relative;
}

.hero-subtitle {
  font-size: clamp(15px, 2.5vw, 18px);
  color: rgba(255,255,255,0.88);
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

/* Country page hero modifier */
.hero-country {
  padding: 36px 0 30px;
}

.hero-country-image {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-top: 20px;
  display: block;
}

/* ===== AD SLOTS ===== */
.ad-container {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--tbc-white);
  border-top: 1px solid var(--tbc-border);
  border-bottom: 1px solid var(--tbc-border);
  padding: 8px 0;
  margin: 0;
}

.ad-leaderboard { min-height: 100px; }
.ad-rectangle {
  min-height: 280px;
  margin: 28px auto;
  max-width: 360px;
  border: 1px solid var(--tbc-border);
  border-radius: var(--radius-md);
}

.ad-placeholder {
  font-size: 11px;
  color: var(--tbc-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ===== MAIN CONTENT ===== */
.main-content { padding: 36px 20px 60px; }

/* ===== CALCULATOR CARD ===== */
.calculator-card {
  background: var(--tbc-white);
  border: 1px solid var(--tbc-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  margin-bottom: 32px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--tbc-dark);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--tbc-border);
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

@media (min-width: 680px) {
  .calc-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 22px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--tbc-mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.form-select,
.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--tbc-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--tbc-dark);
  background: var(--tbc-white);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234a5550' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

.form-select:focus,
.form-input:focus {
  outline: none;
  border-color: var(--tbc-green);
  box-shadow: 0 0 0 3px rgba(26,107,74,0.12);
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--tbc-soft);
  margin-top: 5px;
}

/* Currency prefix input */
.input-prefix-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--tbc-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-prefix-wrap:focus-within {
  border-color: var(--tbc-green);
  box-shadow: 0 0 0 3px rgba(26,107,74,0.12);
}

.input-prefix {
  padding: 11px 12px;
  background: var(--tbc-green-light);
  color: var(--tbc-green);
  font-weight: 600;
  font-size: 15px;
  border-right: 1.5px solid var(--tbc-border);
  min-width: 38px;
  text-align: center;
}

.input-prefix-wrap .form-input {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.input-prefix-wrap .form-input:focus {
  box-shadow: none;
  border-color: transparent;
}

/* ===== TIP BUTTONS ===== */
.tip-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.tip-btn {
  padding: 8px 16px;
  border: 1.5px solid var(--tbc-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--tbc-mid);
  background: var(--tbc-white);
  transition: all var(--transition);
}

.tip-btn:hover {
  border-color: var(--tbc-green);
  color: var(--tbc-green);
  background: var(--tbc-green-light);
}

.tip-btn.active {
  border-color: var(--tbc-green);
  background: var(--tbc-green);
  color: var(--tbc-white);
}

.custom-tip-input {
  font-size: 14px;
  padding: 8px 12px;
}

/* ===== PEOPLE COUNTER ===== */
.people-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.people-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--tbc-border);
  background: var(--tbc-white);
  font-size: 20px;
  color: var(--tbc-green);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
}

.people-btn:hover {
  background: var(--tbc-green-light);
  border-color: var(--tbc-green);
}

.people-count {
  font-size: 22px;
  font-weight: 600;
  color: var(--tbc-dark);
  min-width: 28px;
  text-align: center;
}

.people-label {
  font-size: 14px;
  color: var(--tbc-soft);
}

/* ===== CALCULATE BUTTON ===== */
.btn-calculate {
  width: 100%;
  padding: 14px;
  background: var(--tbc-green);
  color: var(--tbc-white);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background var(--transition), transform var(--transition);
  margin-bottom: 10px;
}

.btn-calculate:hover { background: var(--tbc-green-mid); transform: translateY(-1px); }
.btn-calculate:active { transform: translateY(0); }

.btn-reset {
  width: 100%;
  padding: 10px;
  background: transparent;
  color: var(--tbc-soft);
  border: 1px solid var(--tbc-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: all var(--transition);
}

.btn-reset:hover {
  color: var(--tbc-error);
  border-color: var(--tbc-error);
}

/* ===== RESULTS PANEL ===== */
.calc-results {
  background: var(--tbc-bg);
  border: 1px solid var(--tbc-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.results-inner { margin-bottom: 20px; }

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--tbc-border);
}

.result-row:last-child { border-bottom: none; }

.result-label {
  font-size: 14px;
  color: var(--tbc-soft);
  font-weight: 500;
}

.result-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--tbc-dark);
  font-family: var(--font-display);
}

.result-tip .result-value { color: var(--tbc-green); }
.result-total .result-value { color: var(--tbc-dark); font-size: 26px; }

/* ===== ETIQUETTE NOTE ===== */
.etiquette-note {
  background: var(--tbc-warn-bg);
  border: 1px solid var(--tbc-warn-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 16px;
}

.etiquette-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

#etiquette-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--tbc-mid);
}

/* ===== NORM BADGE ===== */
.norm-badge-wrap { margin-top: 10px; }

.norm-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.norm-expected  { background: #fde8e8; color: #a32d2d; }
.norm-common    { background: var(--tbc-green-light); color: var(--tbc-green); }
.norm-optional  { background: #e8f0fe; color: #1a56db; }
.norm-rare      { background: #f3f4f6; color: #6b7280; }
.norm-offence   { background: #fef3c7; color: #92400e; }

/* ===== AFFILIATE SECTION ===== */
.affiliate-section {
  background: var(--tbc-white);
  border: 1px solid var(--tbc-border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 36px;
}

.affiliate-title {
  font-family: var(--font-display);
  font-size: 22px;
  margin-bottom: 6px;
  color: var(--tbc-dark);
}

.affiliate-intro {
  font-size: 14px;
  color: var(--tbc-soft);
  margin-bottom: 20px;
}

.affiliate-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 600px) {
  .affiliate-cards { grid-template-columns: 1fr 1fr; }
}

.affiliate-card {
  display: flex;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--tbc-border);
  border-radius: var(--radius-md);
  background: var(--tbc-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.affiliate-card:hover {
  border-color: var(--tbc-green);
  box-shadow: var(--shadow-sm);
}

.affiliate-card-logo { font-size: 28px; flex-shrink: 0; }

.affiliate-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--tbc-dark);
  margin-bottom: 4px;
}

.affiliate-card-desc {
  font-size: 13px;
  color: var(--tbc-soft);
  line-height: 1.5;
  margin-bottom: 10px;
}

.affiliate-btn {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--tbc-green);
  text-decoration: none;
  border-bottom: 1.5px solid var(--tbc-green);
  transition: color var(--transition);
}

.affiliate-btn:hover { color: var(--tbc-green-mid); }

/* ===== COUNTRY DIRECTORY ===== */
.country-directory { margin-bottom: 40px; }

.section-title {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--tbc-dark);
  margin-bottom: 8px;
}

.section-intro {
  font-size: 15px;
  color: var(--tbc-soft);
  margin-bottom: 20px;
}

.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.country-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  background: var(--tbc-white);
  border: 1px solid var(--tbc-border);
  border-radius: var(--radius-md);
  text-align: center;
  text-decoration: none;
  color: var(--tbc-dark);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.country-card:hover {
  border-color: var(--tbc-green);
  background: var(--tbc-green-light);
  color: var(--tbc-green);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.country-flag { font-size: 26px; font-family: var(--font-flags); }
.etiquette-icon { font-family: var(--font-flags); }
.hero-title { font-family: var(--font-display); }
/* Flag emoji in hero titles on country pages */
.flag-emoji { font-family: var(--font-flags); }

.country-norm-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.tag-expected { background: #fde8e8; color: #a32d2d; }
.tag-optional { background: var(--tbc-green-light); color: var(--tbc-green); }
.tag-rare     { background: #f3f4f6; color: #6b7280; }

/* ===== EMAIL OPT-IN ===== */
.optin-section {
  background: linear-gradient(135deg, var(--tbc-dark) 0%, #2d3d35 100%);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
  margin-bottom: 40px;
  color: var(--tbc-white);
}

.optin-title {
  font-family: var(--font-display);
  font-size: 26px;
  margin-bottom: 10px;
  color: var(--tbc-white);
}

.optin-desc {
  font-size: 15px;
  color: rgba(255,255,255,0.78);
  max-width: 480px;
  margin: 0 auto 22px;
}

.optin-form {
  display: flex;
  gap: 10px;
  max-width: 460px;
  margin: 0 auto 10px;
  flex-wrap: wrap;
}

.optin-email {
  flex: 1;
  min-width: 220px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: var(--font-body);
}

.optin-btn {
  padding: 12px 22px;
  background: var(--tbc-gold);
  color: var(--tbc-white);
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background var(--transition);
  white-space: nowrap;
}

.optin-btn:hover { background: #b07d1e; }

.optin-privacy {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

/* ===== FAQ SECTION ===== */
.faq-section { margin-bottom: 40px; }

.faq-list { display: flex; flex-direction: column; gap: 8px; }

.faq-item {
  background: var(--tbc-white);
  border: 1px solid var(--tbc-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  text-align: left;
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--tbc-dark);
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: background var(--transition);
}

.faq-question::after {
  content: '+';
  font-size: 20px;
  color: var(--tbc-green);
  font-weight: 300;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.faq-question[aria-expanded="true"] { background: var(--tbc-green-light); }
.faq-question[aria-expanded="true"]::after { content: '−'; }

.faq-answer {
  display: none;
  padding: 0 20px 18px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--tbc-mid);
}

.faq-answer.open { display: block; }

/* ===== COUNTRY PAGE — SPECIFIC ===== */
.country-intro-section {
  background: var(--tbc-white);
  border: 1px solid var(--tbc-border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 28px;
}

.country-intro-section h2 {
  font-family: var(--font-display);
  font-size: 22px;
  margin-bottom: 12px;
  color: var(--tbc-dark);
}

.country-intro-section p {
  font-size: 15px;
  color: var(--tbc-mid);
  line-height: 1.7;
  margin-bottom: 10px;
}

.tipping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 16px;
}

.tipping-table th {
  background: var(--tbc-green-light);
  color: var(--tbc-green);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tipping-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--tbc-border);
  color: var(--tbc-mid);
  vertical-align: top;
}

.tipping-table tr:last-child td { border-bottom: none; }
.tipping-table tr:hover td { background: var(--tbc-bg); }

.tip-amount-cell {
  font-weight: 600;
  color: var(--tbc-green);
  white-space: nowrap;
}

/* Breadcrumb nav */
.breadcrumb {
  font-size: 13px;
  color: var(--tbc-soft);
  margin-bottom: 20px;
}

.breadcrumb a { color: var(--tbc-green); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 6px; }

/* ===== FOOTER ===== */
.site-footer {
  background: var(--tbc-dark);
  color: rgba(255,255,255,0.7);
  padding: 36px 0;
  margin-top: 20px;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.site-footer .logo-text { color: var(--tbc-white); font-size: 18px; }
.site-footer .logo-text em { color: var(--tbc-gold); }

.footer-tagline {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
}

.footer-nav {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-nav a {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-nav a:hover { color: var(--tbc-white); }

.footer-legal {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  max-width: 520px;
  line-height: 1.6;
}

.footer-legal a { color: rgba(255,255,255,0.55); text-decoration: underline; }

/* ===== UTILITY ===== */
.text-center { text-align: center; }
.mt-sm { margin-top: 12px; }
.mt-md { margin-top: 24px; }
.mt-lg { margin-top: 40px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .calculator-card { padding: 20px 16px; }
  .affiliate-section { padding: 20px 16px; }
  .optin-section { padding: 28px 16px; }
  .country-intro-section { padding: 20px 16px; }
  .optin-form { flex-direction: column; }
  .optin-email, .optin-btn { width: 100%; }
  .result-value { font-size: 18px; }
  .result-total .result-value { font-size: 22px; }
  .country-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

@media (min-width: 900px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
    align-items: flex-start;
  }
}
