<?php
$fonts = [
    ['file' => 'fonts/opensans/regular/opensans-400.woff2',                                  'type' => 'font/woff2'],
    ['file' => 'fonts/opensans/semibold/opensans-600.woff2',                                 'type' => 'font/woff2'],
    ['file' => 'fonts/google-fonts/montserrat-v31-latin/montserrat-v31-latin-300.woff2',     'type' => 'font/woff2'],
    ['file' => 'fonts/google-fonts/montserrat-v31-latin/montserrat-v31-latin-regular.woff2', 'type' => 'font/woff2'],
    ['file' => 'fonts/google-fonts/montserrat-v31-latin/montserrat-v31-latin-500.woff2',     'type' => 'font/woff2'],
    ['file' => 'fonts/google-fonts/montserrat-v31-latin/montserrat-v31-latin-600.woff2',     'type' => 'font/woff2'],
    ['file' => 'fonts/google-fonts/montserrat-v31-latin/montserrat-v31-latin-700.woff2',     'type' => 'font/woff2'],
    ['file' => 'icon-fonts/font/porto-icons.woff2',                                          'type' => 'font/woff2'],
    ['file' => 'fonts/icomoon/icomoon.woff?qgxyg5',                                          'type' => 'font/woff'],
    ['file' => 'font-awesome/fonts/fontawesome-webfont.woff2?v=4.7.0',                       'type' => 'font/woff2'],
];

$opensans400 = $escaper->escapeUrl($block->getViewFileUrl('fonts/opensans/regular/opensans-400.woff2'));
$opensans600 = $escaper->escapeUrl($block->getViewFileUrl('fonts/opensans/semibold/opensans-600.woff2'));
$mont300     = $escaper->escapeUrl($block->getViewFileUrl('fonts/google-fonts/montserrat-v31-latin/montserrat-v31-latin-300.woff2'));
$mont400     = $escaper->escapeUrl($block->getViewFileUrl('fonts/google-fonts/montserrat-v31-latin/montserrat-v31-latin-regular.woff2'));
$mont500     = $escaper->escapeUrl($block->getViewFileUrl('fonts/google-fonts/montserrat-v31-latin/montserrat-v31-latin-500.woff2'));
$mont600     = $escaper->escapeUrl($block->getViewFileUrl('fonts/google-fonts/montserrat-v31-latin/montserrat-v31-latin-600.woff2'));
$mont700     = $escaper->escapeUrl($block->getViewFileUrl('fonts/google-fonts/montserrat-v31-latin/montserrat-v31-latin-700.woff2'));
$portoIcons  = $escaper->escapeUrl($block->getViewFileUrl('icon-fonts/font/porto-icons.woff2'));
$fontawesome = $escaper->escapeUrl($block->getViewFileUrl('font-awesome/fonts/fontawesome-webfont.woff2')) . '?v=4.7.0';
?>
<?php foreach ($fonts as $font): ?>
<link rel="preload"
      href="<?= $escaper->escapeUrl($block->getViewFileUrl($font['file'])) ?>"
      as="font"
      type="<?= $escaper->escapeHtmlAttr($font['type']) ?>"
      crossorigin="anonymous">
<?php endforeach; ?>
<style>
/* @font-face critice inlinate — elimina lantul HTML→CSS→fonts_CSS→font_files */
@font-face{font-family:'Open Sans';src:url('<?= $opensans400 ?>') format('woff2');font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:'Open Sans';src:url('<?= $opensans600 ?>') format('woff2');font-weight:600;font-style:normal;font-display:swap}
@font-face{font-family:'Montserrat';src:url('<?= $mont300 ?>') format('woff2');font-weight:300;font-style:normal;font-display:swap}
@font-face{font-family:'Montserrat';src:url('<?= $mont400 ?>') format('woff2');font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:'Montserrat';src:url('<?= $mont500 ?>') format('woff2');font-weight:500;font-style:normal;font-display:swap}
@font-face{font-family:'Montserrat';src:url('<?= $mont600 ?>') format('woff2');font-weight:600;font-style:normal;font-display:swap}
@font-face{font-family:'Montserrat';src:url('<?= $mont700 ?>') format('woff2');font-weight:700;font-style:normal;font-display:swap}
@font-face{font-family:'porto-icons';src:url('<?= $portoIcons ?>') format('woff2');font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:'FontAwesome';src:url('<?= $fontawesome ?>') format('woff2');font-weight:normal;font-style:normal;font-display:swap}
</style>
